Class: Jobs::PendingQueuedPostsReminder
- Inherits:
-
Scheduled
show all
- Defined in:
- app/jobs/scheduled/pending_queued_posts_reminder.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Scheduled
#perform
Methods inherited from Base
acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately
Class Method Details
.last_notified_key ⇒ Object
51
52
53
|
# File 'app/jobs/scheduled/pending_queued_posts_reminder.rb', line 51
def self.last_notified_key
"last_notified_queued_post_id"
end
|
Instance Method Details
#execute(args) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/jobs/scheduled/pending_queued_posts_reminder.rb', line 7
def execute(args)
return true if SiteSetting.notify_about_queued_posts_after.zero?
queued_post_ids = should_notify_ids
if queued_post_ids.size > 0 && last_notified_id.to_i < queued_post_ids.max
PostCreator.create(
Discourse.system_user,
target_group_names: Group[:moderators].name,
archetype: Archetype.private_message,
subtype: TopicSubtype.system_message,
title:
I18n.t(
"system_messages.queued_posts_reminder.subject_template",
count: queued_post_ids.size,
),
raw:
I18n.t(
"system_messages.queued_posts_reminder.text_body_template",
base_url: Discourse.base_url,
),
)
self.last_notified_id = queued_post_ids.max
end
true
end
|
#last_notified_id ⇒ Object
43
44
45
|
# File 'app/jobs/scheduled/pending_queued_posts_reminder.rb', line 43
def last_notified_id
(i = Discourse.redis.get(self.class.last_notified_key)) && i.to_i
end
|
#last_notified_id=(arg) ⇒ Object
47
48
49
|
# File 'app/jobs/scheduled/pending_queued_posts_reminder.rb', line 47
def last_notified_id=(arg)
Discourse.redis.set(self.class.last_notified_key, arg)
end
|
#should_notify_ids ⇒ Object
36
37
38
39
40
41
|
# File 'app/jobs/scheduled/pending_queued_posts_reminder.rb', line 36
def should_notify_ids
ReviewableQueuedPost
.pending
.where("created_at < ?", SiteSetting.notify_about_queued_posts_after.to_f.hours.ago)
.pluck(:id)
end
|