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
- #process_employees ⇒ Object
- #process_pending_requests ⇒ Object
- #process_pending_work_schedules ⇒ Object
Instance Method Details
#perform ⇒ Object
7 8 9 10 11 |
# File 'app/workers/time_off_worker.rb', line 7 def perform process_pending_requests process_pending_work_schedules process_employees end |
#process_employees ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/workers/time_off_worker.rb', line 30 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
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/workers/time_off_worker.rb', line 18 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
13 14 15 16 |
# File 'app/workers/time_off_worker.rb', line 13 def process_pending_work_schedules pending_schedules = WorkSchedule.where(state: 'pending') WorkforceMailer.pending_work_schedules(pending_schedules).deliver_now if pending_schedules.any? end |