OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Remove scheduling DigestJobs from WorkFlowJob
Wieland Lindenthal86427c2b78af
diff --git a/app/workers/mails/digest_job.rb b/app/workers/mails/digest_job.rbindex 0aa872ecf4e..ffa99c93b5e 100644--- a/app/workers/mails/digest_job.rb+++ b/app/workers/mails/digest_job.rb@@ -29,35 +29,6 @@#++class Mails::DigestJob < Mails::DeliverJob- class << self- def schedule(notification)- # This alone is vulnerable to the edge case of the Mails::DigestJob- # having started but not completed when a new digest notification is generated.- # To cope with it, the Mails::DigestJob as its first action sets all digest notifications- # to being handled even though they are still processed.- return if digest_job_already_scheduled?(notification)-- set(wait_until: execution_time(notification.recipient))- .perform_later(notification.recipient)- end-- private-- def execution_time(user)- zone = (user.time_zone || ActiveSupport::TimeZone.new('UTC'))-- zone.parse(Setting.notification_email_digest_time) + 1.day- end-- def digest_job_already_scheduled?(notification)- Notification- .mail_digest_before(recipient: notification.recipient,- time: notification.created_at)- .where.not(id: notification.id)- .exists?- end- end-privatedef render_maildiff --git a/app/workers/notifications/workflow_job.rb b/app/workers/notifications/workflow_job.rbindex e562658b481..1b0c4593c2a 100644--- a/app/workers/notifications/workflow_job.rb+++ b/app/workers/notifications/workflow_job.rb@@ -73,13 +73,5 @@ class Notifications::WorkflowJob < ApplicationJob.new(notification).callend-- Notification- .where(id: notification_ids)- .unread_mail_digest- .each do |notification|- Mails::DigestJob- .schedule(notification)- endendenddiff --git a/spec/workers/notifications/workflow_job_spec.rb b/spec/workers/notifications/workflow_job_spec.rbindex 8a8a2e1cc9b..d253c8cc171 100644--- a/spec/workers/notifications/workflow_job_spec.rb+++ b/spec/workers/notifications/workflow_job_spec.rb@@ -109,15 +109,8 @@ describe Notifications::WorkflowJob, type: :model doservice_instanceend- let!(:digest_job) do- allow(Mails::DigestJob)- .to receive(:schedule)- end-before do- scope = class_double(Notification,- unread_mail: [notifications.first],- unread_mail_digest: [notifications.last])+ scope = class_double(Notification, unread_mail: [notifications.first])allow(Notification).to receive(:where)@@ -131,14 +124,6 @@ describe Notifications::WorkflowJob, type: :model doexpect(mail_service).to have_received(:call)end-- it 'schedules a digest job for all notifications that are marked for the digest' do- perform_job-- expect(Mails::DigestJob)- .to have_received(:schedule)- .with(notifications.last)- endendendend