Skip to content

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

place 24 hour limit on interval for date alerts and reminders

ulferts3753de224ab5
diff --git a/app/workers/cron/quarter_hour_schedule_job.rb b/app/workers/cron/quarter_hour_schedule_job.rb
index dc9b7b93b13..015defc5adf 100644
--- a/app/workers/cron/quarter_hour_schedule_job.rb
+++ b/app/workers/cron/quarter_hour_schedule_job.rb
@@ -69,7 +69,11 @@ module Cron::QuarterHourScheduleJob
.first
if predecessor
- predecessor.cron_at + 15.minutes
+ # To ovoid the jobs spanning a very long time e.g after a longer downtime, the interval
+ # is limited to a somewhat arbitrary 24 hours.
+ # On the other hand the two jobs currently making use of this module have a time reference where
+ # it would not make sense to send very old data (i.e. reminders or date alerts)
+ [upper_boundary - 24.hours, predecessor.cron_at + 15.minutes].max
else
upper_boundary
end
diff --git a/spec/workers/notifications/schedule_reminder_mails_job_spec.rb b/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
index 61ab0eb8704..ef9c908c19c 100644
--- a/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
+++ b/spec/workers/notifications/schedule_reminder_mails_job_spec.rb
@@ -116,5 +116,18 @@ RSpec.describe Notifications::ScheduleReminderMailsJob, type: :job do
let(:expected_upper_boundary) { job_cron_at }
end
end
+
+ context "when there is a predecessor job with a cron_at more than 24 hours before" do
+ let(:previous_job_cron_at) { job_cron_at - 25.hours }
+
+ before do
+ previous_job
+ end
+
+ it_behaves_like "schedules reminder mails" do
+ let(:expected_lower_boundary) { job_cron_at - 24.hours }
+ let(:expected_upper_boundary) { job_cron_at }
+ end
+ end
end
end