DEV: Convert notify_about_flags_after to float (#16633)

Add support for `notify_about_flags_after` to be set to a float.
This commit is contained in:
Isaac Janzen 2022-05-04 11:19:43 -05:00 committed by GitHub
parent 64f03a7d05
commit dcc7f2a55e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -3,7 +3,7 @@
module Jobs
class PendingReviewablesReminder < ::Jobs::Scheduled
every 1.hour
every 15.minutes
attr_reader :sent_reminder
@ -14,7 +14,7 @@ module Jobs
reviewable_ids = Reviewable
.pending
.default_visible
.where('latest_score < ?', SiteSetting.notify_about_flags_after.to_i.hours.ago)
.where('latest_score < ?', SiteSetting.notify_about_flags_after.to_f.hours.ago)
.order('id DESC')
.pluck(:id)

View File

@ -2237,7 +2237,9 @@ uncategorized:
default: -1
hidden: true
notify_about_flags_after: 48
notify_about_flags_after:
type: float
default: 48
show_create_topics_notice:
client: true

View File

@ -24,6 +24,20 @@ describe Jobs::PendingReviewablesReminder do
end
end
context "notify_about_flags_after accepts a float" do
before { SiteSetting.notify_about_flags_after = 0.25 }
it "doesn't send message when flags are less than 15 minutes old" do
create_flag(14.minutes.ago)
expect(execute.sent_reminder).to eq(false)
end
it "sends message when there is a flag older than 15 minutes" do
create_flag(16.minutes.ago)
expect(execute.sent_reminder).to eq(true)
end
end
context "notify_about_flags_after is 48" do
before do
SiteSetting.notify_about_flags_after = 48