Class: TimeOffWorker
- Inherits:
-
Object
- Object
- TimeOffWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/time_off_worker.rb
Overview
Sidekiq worker: time off.
Instance Method Summary collapse
-
#perform ⇒ Object
Runs the job.
-
#process_employees ⇒ Object
Process employees.
-
#process_pending_requests ⇒ Object
Process pending requests.
-
#process_pending_work_schedules ⇒ Object
Process pending work schedules.
Instance Method Details
#perform ⇒ Object
Runs the job.
10 11 12 13 14 |
# File 'app/workers/time_off_worker.rb', line 10 def perform process_pending_requests process_pending_work_schedules process_employees end |
#process_employees ⇒ Object
Process employees.
42 43 44 45 46 47 48 49 50 |
# File 'app/workers/time_off_worker.rb', line 42 def process_employees Employee.active_employees.find_each do |employee| employee.process_accruals employee.process_time_off_requests employee.process_work_schedule_transitions employee.process_rollover_and_expiry employee.process_policy_transitions end end |
#process_pending_requests ⇒ Object
Process pending requests.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/workers/time_off_worker.rb', line 27 def process_pending_requests # Reminder sent to managers for pending requests pending_reminder_requests = TimeOffRequest.where(state: 'requested').where(created_at: 3.days.ago..1.day.ago) pending_reminder_requests.each do |request| WorkforceMailer.new_time_off_request(request).deliver_now end # Final reminder sent to all managers for pending requests pending_requests = TimeOffRequest.where(state: 'requested').where('created_at > ?', 3.days.ago) WorkforceMailer.pending_time_off_requests(pending_requests).deliver_now if pending_requests.any? end |
#process_pending_work_schedules ⇒ Object
Process pending work schedules.
19 20 21 22 |
# File 'app/workers/time_off_worker.rb', line 19 def process_pending_work_schedules pending_schedules = WorkSchedule.where(state: 'pending') WorkforceMailer.pending_work_schedules(pending_schedules).deliver_now if pending_schedules.any? end |