Class: Collavre::Topics::OrphanedCronNotifier

Inherits:
Object
  • Object
show all
Includes:
Crons::RecurringTaskArguments
Defined in:
app/services/collavre/topics/orphaned_cron_notifier.rb

Overview

When a Topic is deleted, find every non-static recurring cron task that targets that topic (topic_id stored inside the task’s arguments JSON) and post a system message into the affected creative’s Main topic so the user knows the cron is now orphaned.

Decision: notify only. The recurring task is intentionally left in place so the user can decide whether to re-point or cancel it.

Instance Method Summary collapse

Constructor Details

#initialize(topic_id:, topic_name:) ⇒ OrphanedCronNotifier

Returns a new instance of OrphanedCronNotifier.



15
16
17
18
# File 'app/services/collavre/topics/orphaned_cron_notifier.rb', line 15

def initialize(topic_id:, topic_name:)
  @topic_id = topic_id
  @topic_name = topic_name
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
# File 'app/services/collavre/topics/orphaned_cron_notifier.rb', line 20

def call
  return if @topic_id.blank?

  matching_tasks.each do |task, args|
    notify_for(task, args)
  end
end