DEV: Convert notify_about_queued_posts_after to accept a float (#16637)

Add support for `notify_about_queued_posts_after` to be set to a float to allow for 15 min increments
This commit is contained in:
Isaac Janzen 2022-05-04 11:33:43 -05:00 committed by GitHub
parent dcc7f2a55e
commit 2381f18eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View File

@ -3,7 +3,7 @@
module Jobs
class PendingQueuedPostsReminder < ::Jobs::Scheduled
every 1.hour
every 15.minutes
def execute(args)
return true unless SiteSetting.notify_about_queued_posts_after > 0
@ -28,7 +28,7 @@ module Jobs
def should_notify_ids
ReviewableQueuedPost.where(status: Reviewable.statuses[:pending]).where(
'created_at < ?', SiteSetting.notify_about_queued_posts_after.hours.ago
'created_at < ?', SiteSetting.notify_about_queued_posts_after.to_f.hours.ago
).pluck(:id)
end

View File

@ -989,6 +989,7 @@ posting:
approve_unless_staged:
default: false
notify_about_queued_posts_after:
type: float
default: 24
auto_close_messages_post_count:
default: 500

View File

@ -14,6 +14,24 @@ describe Jobs::PendingQueuedPostsReminder do
end
end
context "notify_about_queued_posts_after accepts a float" do
before do
SiteSetting.notify_about_queued_posts_after = 0.25
job.last_notified_id = nil
end
it "creates system message if there are new queued posts" do
Fabricate(:reviewable_queued_post, created_at: 16.minutes.ago)
Fabricate(:reviewable_queued_post, created_at: 14.minutes.ago)
# expect 16 minute post to be picked up but not 14 min post
expect { job.execute({}) }.to change { Post.count }.by(1)
expect(Topic.where(
subtype: TopicSubtype.system_message,
title: I18n.t('system_messages.queued_posts_reminder.subject_template', count: 1)
).exists?).to eq(true)
end
end
context "notify_about_queued_posts_after is 24" do
before do
SiteSetting.notify_about_queued_posts_after = 24