Use cron for sending emails

This commit is contained in:
Stuart Nelson 2018-02-10 14:38:31 +01:00 committed by Sean McGivern
parent ff830bc1e1
commit 9d81d5aa89
7 changed files with 8 additions and 19 deletions

View file

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

View file

@ -27,7 +27,6 @@ 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)
schedule_due_date_email(issuable)
super super
end end

View file

@ -13,10 +13,6 @@ 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, [])
@ -27,9 +23,6 @@ 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)

View file

@ -18,6 +18,7 @@
- cronjob:stuck_import_jobs - cronjob:stuck_import_jobs
- cronjob:stuck_merge_jobs - cronjob:stuck_merge_jobs
- cronjob:trending_projects - cronjob:trending_projects
- cronjob:issue_due
- gcp_cluster:cluster_install_app - gcp_cluster:cluster_install_app
- gcp_cluster:cluster_provision - gcp_cluster:cluster_provision
@ -78,7 +79,6 @@
- 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

View file

@ -1,9 +1,9 @@
class IssueDueWorker class IssueDueWorker
include ApplicationWorker include ApplicationWorker
include CronjobQueue
def perform(issue_id) def perform
issue = Issue.find_by_id(issue_id) Issue.where(due_date: Date.today).find_each do |issue|
if issue.due_date == Date.today
NotificationService.new.issue_due_email(issue) NotificationService.new.issue_due_email(issue)
end end
end end

View file

@ -431,6 +431,10 @@ Settings.cron_jobs['pages_domain_verification_cron_worker'] ||= Settingslogic.ne
Settings.cron_jobs['pages_domain_verification_cron_worker']['cron'] ||= '*/15 * * * *' Settings.cron_jobs['pages_domain_verification_cron_worker']['cron'] ||= '*/15 * * * *'
Settings.cron_jobs['pages_domain_verification_cron_worker']['job_class'] = 'PagesDomainVerificationCronWorker' Settings.cron_jobs['pages_domain_verification_cron_worker']['job_class'] = 'PagesDomainVerificationCronWorker'
Settings.cron_jobs['issue_due_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['issue_due_worker']['cron'] ||= '50 00 * * *'
Settings.cron_jobs['issue_due_worker']['job_class'] = 'IssueDueWorker'
# #
# GitLab Shell # GitLab Shell
# #

View file

@ -48,7 +48,6 @@
- [authorized_projects, 1] - [authorized_projects, 1]
- [expire_build_instance_artifacts, 1] - [expire_build_instance_artifacts, 1]
- [group_destroy, 1] - [group_destroy, 1]
- [issue_due, 1]
- [irker, 1] - [irker, 1]
- [namespaceless_project_destroy, 1] - [namespaceless_project_destroy, 1]
- [project_cache, 1] - [project_cache, 1]