Class: Jobs::BookmarkReminderNotifications

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/bookmark_reminder_notifications.rb

Overview

Runs periodically to send out bookmark reminders, capped at 300 at a time. Any leftovers will be caught in the next run, because the reminder_at column is set to NULL once a reminder has been sent.

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

.max_reminder_notifications_per_runObject



10
11
12
13
# File 'app/jobs/scheduled/bookmark_reminder_notifications.rb', line 10

def self.max_reminder_notifications_per_run
  @@max_reminder_notifications_per_run ||= 300
  @@max_reminder_notifications_per_run
end

.max_reminder_notifications_per_run=(max) ⇒ Object



15
16
17
# File 'app/jobs/scheduled/bookmark_reminder_notifications.rb', line 15

def self.max_reminder_notifications_per_run=(max)
  @@max_reminder_notifications_per_run = max
end

Instance Method Details

#execute(args = nil) ⇒ Object



19
20
21
22
23
24
# File 'app/jobs/scheduled/bookmark_reminder_notifications.rb', line 19

def execute(args = nil)
  bookmarks = Bookmark.pending_reminders.includes(:user).order("reminder_at ASC")
  bookmarks
    .limit(BookmarkReminderNotifications.max_reminder_notifications_per_run)
    .each { |bookmark| BookmarkReminderNotificationHandler.new(bookmark).send_notification }
end