Class: CompanyHolidaySyncWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/company_holiday_sync_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(id, action = 'create') ⇒ Object

Sync a single company holiday to all employees of that country

Parameters:

  • id (Integer)

    the company holiday ID

  • action (String) (defaults to: 'create')

    'create', 'update', or 'destroy'



9
10
11
12
13
14
15
16
17
18
19
# File 'app/workers/company_holiday_sync_worker.rb', line 9

def perform(id, action = 'create')
  holiday = CompanyHoliday.find_by(id: id)
  return unless holiday

  results = holiday.sync_to_all_employees(action)

  Rails.logger.info(
    "CompanyHolidaySyncWorker: Holiday '#{holiday.holiday_name}' (#{action}) - " \
    "Synced: #{results[:synced]}, Skipped: #{results[:skipped]}, Failed: #{results[:failed]}"
  )
end