Class: NotificationServiceWorkers::CookingReminderWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/notification_service_workers/cooking_reminder_worker.rb

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(id, remind_at) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/notification_service_workers/cooking_reminder_worker.rb', line 6

def perform(id, remind_at)
  reservation = ::Reservation.fetch(id)
  return unless reservation.delivery?

   = GenericNote.find_by(parent: reservation)
  return false if .blank?
  return false unless remind_at == .note[:remind_cooking_at]
  return false unless reservation.ack && reservation.active

  time = Time.parse(.note[:remind_cooking_at]).in_time_zone('UTC')
  return false if (time + 15.minutes).past? # in case system executing failed job

  push_to_staff = ::PushNotification.new 'staff'
  push_to_staff.publish_event(:cooking_reminder, object_id: reservation.id)
end