Class: Mensa::RecurringExportsJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/mensa/recurring_exports_job.rb

Overview

Sweeps recurring exports and re-enqueues any whose next scheduled run is due. This job is intended to be invoked by a daily cron entry or scheduler.

Instance Method Summary collapse

Instance Method Details

#perform(reference_time = Time.current) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'app/jobs/mensa/recurring_exports_job.rb', line 7

def perform(reference_time = Time.current)
  reference_time = reference_time.in_time_zone if reference_time.respond_to?(:in_time_zone)

  Mensa::Export.repeating.find_each do |export|
    next unless export.repeat_due?(reference_time)

    Mensa::ExportJob.perform_later(export)
  end
end