Class: ActivityProductionCheckJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/jobs/activity_production_check_job.rb

Instance Method Summary collapse

Instance Method Details

#performObject


4
5
6
7
8
9
10
11
12
13
# File 'lib/jobs/activity_production_check_job.rb', line 4

def perform
  Ekylibre::Tenant.switch_each do
    today = Date.today
    if ActivityProduction.where(started_on: today).any?
      Ekylibre::Hook.publish(:activity_production_start)
    elsif ActivityProduction.where(stopped_on: today - 1).any?
      Ekylibre::Hook.publish(:activity_production_stop)
    end
  end
end