Class: MissedFreightPickupSweep

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/missed_freight_pickup_sweep.rb

Overview

Hourly sweep that pages ops when a Freightquote LTL booking's pickup
window has passed without a LOAD PICKED UP event arriving from CHR.

The catch for DE787078-class failures: when a carrier verbally tells
CHR they can't perform the service (Shipby + inside delivery, in
DE787078's case) no electronic event fires, so subscribing to CHR's
webhooks alone wouldn't help. The signal we DO have is the absence
of LOAD PICKED UP after the booked pickupByDate.

Triggers an ErrorReporting.warning per stale delivery; gated on a
7-day Rails.cache flag so the same delivery doesn't re-alert every
hour while ops works the issue.

Scheduled hourly via sidekiq-scheduler — see
config/sidekiq_production_schedule.yml and
config/sidekiq_staging_schedule.yml.

Constant Summary collapse

LOOKBACK_WINDOW =

Don't scan the entire history — only deliveries booked recently.

30.days
ACTIVE_PICKUP_STATES =

States where we still expect the carrier to pick up. Past these the
delivery has moved on (shipped/invoiced) or been cancelled.

%w[
  pending_carrier_confirm
  pending_ship_confirm
].freeze
ALERT_CACHE_TTL =
7.days

Instance Method Summary collapse

Instance Method Details

#performObject



36
37
38
39
40
41
42
43
# File 'app/workers/missed_freight_pickup_sweep.rb', line 36

def perform
  candidates.each do |booked_event|
    delivery = booked_event.delivery
    next unless should_alert?(delivery, booked_event)

    alert!(delivery, booked_event)
  end
end