Commit bebced8f authored by Stuart Nelson's avatar Stuart Nelson Committed by Sean McGivern

creating background job

parent 391732a2
...@@ -7,6 +7,12 @@ module Issues ...@@ -7,6 +7,12 @@ module Issues
hook_data hook_data
end end
def schedule_due_date_email(issuable)
return if issuable.due_date.nil?
IssueDueWorker.perform_at(issuable.due_date.to_time, issuable.id)
end
def reopen_service def reopen_service
Issues::ReopenService Issues::ReopenService
end end
......
...@@ -27,6 +27,8 @@ module Issues ...@@ -27,6 +27,8 @@ module Issues
todo_service.new_issue(issuable, current_user) todo_service.new_issue(issuable, current_user)
user_agent_detail_service.create user_agent_detail_service.create
resolve_discussions_with_issue(issuable) resolve_discussions_with_issue(issuable)
# TODO: Create the scheduled due date email
schedule_due_date_email(issuable)
super super
end end
......
...@@ -13,6 +13,10 @@ module Issues ...@@ -13,6 +13,10 @@ module Issues
spam_check(issue, current_user) spam_check(issue, current_user)
end end
def after_update(issue)
schedule_due_date_email(issue)
end
def handle_changes(issue, options) def handle_changes(issue, options)
old_associations = options.fetch(:old_associations, {}) old_associations = options.fetch(:old_associations, {})
old_labels = old_associations.fetch(:labels, []) old_labels = old_associations.fetch(:labels, [])
...@@ -23,6 +27,9 @@ module Issues ...@@ -23,6 +27,9 @@ module Issues
todo_service.mark_pending_todos_as_done(issue, current_user) todo_service.mark_pending_todos_as_done(issue, current_user)
end end
# TODO: If due date doesn't change, don't bother updating the due date
# email worker
if issue.previous_changes.include?('title') || if issue.previous_changes.include?('title') ||
issue.previous_changes.include?('description') issue.previous_changes.include?('description')
todo_service.update_issue(issue, current_user, old_mentioned_users) todo_service.update_issue(issue, current_user, old_mentioned_users)
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
- group_destroy - group_destroy
- invalid_gpg_signature_update - invalid_gpg_signature_update
- irker - irker
- issue_due
- merge - merge
- namespaceless_project_destroy - namespaceless_project_destroy
- new_issue - new_issue
......
class IssueDueWorker
include ApplicationWorker
def perform(issue_id)
issue = Issue.find_by_id(issue_id)
# How do we want to deal with noops?
if issue.due_date == Date.today
# execute
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment