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

adapt to changes in ranges in 3.4.1

ulferts0155c22aded0
diff --git a/app/models/users/scopes/having_reminder_mail_to_send.rb b/app/models/users/scopes/having_reminder_mail_to_send.rb
index f9170672bf0..3ba8f050556 100644
--- a/app/models/users/scopes/having_reminder_mail_to_send.rb
+++ b/app/models/users/scopes/having_reminder_mail_to_send.rb
@@ -183,8 +183,13 @@ module Users::Scopes
# The last quarter is the one smaller than the latest time. But needs to be at least equal to the first quarter.
last_quarter = [first_quarter, latest_time.change(min: latest_time.min / 15 * 15)].max
- (first_quarter.to_i..last_quarter.to_i)
- .step(15.minutes)
+ quarters = if first_quarter == last_quarter
+ [first_quarter]
+ else
+ (first_quarter.to_i..last_quarter.to_i).step(15.minutes)
+ end
+
+ quarters
.map do |time|
Time.zone.at(time)
end
diff --git a/app/workers/notifications/schedule_date_alerts_notifications_job.rb b/app/workers/notifications/schedule_date_alerts_notifications_job.rb
index 7628edcc73d..b7d914700fc 100644
--- a/app/workers/notifications/schedule_date_alerts_notifications_job.rb
+++ b/app/workers/notifications/schedule_date_alerts_notifications_job.rb
@@ -35,7 +35,7 @@ module Notifications
def perform
return unless EnterpriseToken.allows_to?(:date_alerts)
- Service.new(every_quater_hour_between_predecessor_cron_at_and_own_cron_at).call
+ Service.new(every_quarter_hour_between_predecessor_cron_at_and_own_cron_at).call
end
# What cannot be controlled is the time at which a job is actually performed.
@@ -70,9 +70,14 @@ module Notifications
# for 1:00 am local time are covered. The sole exception would be the case where previously finished jobs
# have been removed from the database and the current job took longer to start executing. This is for now
# an accepted shortcoming as the likelihood of this happening is considered to be very low.
- def every_quater_hour_between_predecessor_cron_at_and_own_cron_at
- (lower_boundary.to_i..upper_boundary.to_i)
- .step(15.minutes)
+ def every_quarter_hour_between_predecessor_cron_at_and_own_cron_at
+ quarters = (lower_boundary.to_i..upper_boundary.to_i).step(15.minutes).to_a
+
+ if quarters.empty? && lower_boundary.present?
+ quarters = [lower_boundary]
+ end
+
+ quarters
.map do |time|
Time.zone.at(time)
end
diff --git a/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb b/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
index 4c01d41ca27..3c143e5b497 100644
--- a/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
+++ b/spec/models/users/scopes/having_reminder_mail_to_send_spec.rb
@@ -380,7 +380,7 @@ RSpec.describe User, ".having_reminder_mail_to_send" do
)
end
let(:scope_upper_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T08:09").utc }
- let(:scope_lower_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T08:00") }
+ let(:scope_lower_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T08:00").utc }
it "contains the user" do
expect(scope)
@@ -399,7 +399,7 @@ RSpec.describe User, ".having_reminder_mail_to_send" do
)
end
let(:scope_upper_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T10:00").utc }
- let(:scope_lower_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T10:00") }
+ let(:scope_lower_boundary_time) { ActiveSupport::TimeZone["Europe/Paris"].parse("2021-09-30T10:00").utc }
it "is empty" do
expect(scope)