Commit 7fa89d7a authored by Stuart Nelson's avatar Stuart Nelson Committed by Sean McGivern
Browse files

creating background job

parent 8f6982b1d3da
......@@ -7,6 +7,12 @@ def hook_data(issue, action, old_associations: {})
hook_data
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
Issues::ReopenService
end
......
......@@ -27,6 +27,8 @@ def after_create(issuable)
todo_service.new_issue(issuable, current_user)
user_agent_detail_service.create
resolve_discussions_with_issue(issuable)
# TODO: Create the scheduled due date email
schedule_due_date_email(issuable)
super
end
......
......@@ -13,6 +13,10 @@ def before_update(issue)
spam_check(issue, current_user)
end
def after_update(issue)
schedule_due_date_email(issue)
end
def handle_changes(issue, options)
old_associations = options.fetch(:old_associations, {})
old_labels = old_associations.fetch(:labels, [])
......@@ -23,6 +27,9 @@ def handle_changes(issue, options)
todo_service.mark_pending_todos_as_done(issue, current_user)
end
# TODO: If due date doesn't change, don't bother updating the due date
# email worker
if issue.previous_changes.include?('title') ||
issue.previous_changes.include?('description')
todo_service.update_issue(issue, current_user, old_mentioned_users)
......
......@@ -78,6 +78,7 @@
- group_destroy
- invalid_gpg_signature_update
- irker
- issue_due
- merge
- namespaceless_project_destroy
- 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