creating background job

This commit is contained in:
Stuart Nelson 2018-02-06 15:54:11 +01:00 committed by Sean McGivern
parent 391732a2c1
commit bebced8fc9
5 changed files with 27 additions and 0 deletions

View file

@ -7,6 +7,12 @@ module Issues
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

View file

@ -27,6 +27,8 @@ module Issues
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

View file

@ -13,6 +13,10 @@ module Issues
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 @@ module Issues
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)

View file

@ -78,6 +78,7 @@
- group_destroy
- invalid_gpg_signature_update
- irker
- issue_due
- merge
- namespaceless_project_destroy
- new_issue

View file

@ -0,0 +1,11 @@
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