Module: ActiveJob::QueueAdapters::SolidQueueExt::RecurringTasks
- Included in:
- ActiveJob::QueueAdapters::SolidQueueExt
- Defined in:
- lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb
Instance Method Summary collapse
- #can_enqueue_recurring_task?(task_id) ⇒ Boolean
- #enqueue_recurring_task(task_id) ⇒ Object
- #find_recurring_task(task_id) ⇒ Object
- #recurring_tasks ⇒ Object
- #supports_recurring_tasks? ⇒ Boolean
Instance Method Details
#can_enqueue_recurring_task?(task_id) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb', line 29 def can_enqueue_recurring_task?(task_id) if task = SolidQueue::RecurringTask.find_by(key: task_id) task.valid? end end |
#enqueue_recurring_task(task_id) ⇒ Object
23 24 25 26 27 |
# File 'lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb', line 23 def enqueue_recurring_task(task_id) if task = SolidQueue::RecurringTask.find_by(key: task_id) task.enqueue(at: Time.now) end end |
#find_recurring_task(task_id) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb', line 16 def find_recurring_task(task_id) if task = SolidQueue::RecurringTask.find_by(key: task_id) recurring_task_attributes_from_solid_queue_recurring_task(task).merge \ last_enqueued_at: recurring_task_last_enqueued_at(task.key).values&.first end end |
#recurring_tasks ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb', line 6 def recurring_tasks tasks = SolidQueue::RecurringTask.all last_enqueued_at_times = recurring_task_last_enqueued_at(tasks.map(&:key)) tasks.collect do |task| recurring_task_attributes_from_solid_queue_recurring_task(task).merge \ last_enqueued_at: last_enqueued_at_times[task.key] end end |
#supports_recurring_tasks? ⇒ Boolean
2 3 4 |
# File 'lib/active_job/queue_adapters/solid_queue_ext/recurring_tasks.rb', line 2 def supports_recurring_tasks? true end |