agent_reemit_job.rb 435 B

12345678910
  1. class AgentReemitJob < ActiveJob::Base
  2. # Given an Agent, re-emit all of agent's events up to (and including) `most_recent_event_id`
  3. def perform(agent, most_recent_event_id, delete_old_events = false)
  4. # `find_each` orders by PK, so events get re-created in the same order
  5. agent.events.where("id <= ?", most_recent_event_id).find_each do |event|
  6. event.reemit!
  7. event.destroy if delete_old_events
  8. end
  9. end
  10. end