mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
parent
dcc7f2a55e
commit
2381f18eba
@ -3,7 +3,7 @@
|
|||||||
module Jobs
|
module Jobs
|
||||||
class PendingQueuedPostsReminder < ::Jobs::Scheduled
|
class PendingQueuedPostsReminder < ::Jobs::Scheduled
|
||||||
|
|
||||||
every 1.hour
|
every 15.minutes
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
return true unless SiteSetting.notify_about_queued_posts_after > 0
|
return true unless SiteSetting.notify_about_queued_posts_after > 0
|
||||||
@ -28,7 +28,7 @@ module Jobs
|
|||||||
|
|
||||||
def should_notify_ids
|
def should_notify_ids
|
||||||
ReviewableQueuedPost.where(status: Reviewable.statuses[:pending]).where(
|
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)
|
).pluck(:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -989,6 +989,7 @@ posting:
|
|||||||
approve_unless_staged:
|
approve_unless_staged:
|
||||||
default: false
|
default: false
|
||||||
notify_about_queued_posts_after:
|
notify_about_queued_posts_after:
|
||||||
|
type: float
|
||||||
default: 24
|
default: 24
|
||||||
auto_close_messages_post_count:
|
auto_close_messages_post_count:
|
||||||
default: 500
|
default: 500
|
||||||
|
@ -14,6 +14,24 @@ describe Jobs::PendingQueuedPostsReminder do
|
|||||||
end
|
end
|
||||||
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
|
context "notify_about_queued_posts_after is 24" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.notify_about_queued_posts_after = 24
|
SiteSetting.notify_about_queued_posts_after = 24
|
||||||
|
Loading…
Reference in New Issue
Block a user