Class: ListingIssues::RetailerProbeCompletedHandler

Inherits:
ApplicationJob
  • Object
show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/listing_issues/retailer_probe_completed_handler.rb

Overview

Reconciles the probed item's retailer_probe listing issues the moment a
probe lands (Events::RetailerProbeCompleted) instead of waiting for the
next daily Sync sweep: a recovered listing clears its
critical out_of_stock_mismatch / not_buyable issue within seconds, and a
newly broken one is raised just as fast. The adapter is item-scoped so a
single probe never triggers the bulk sweep's full-catalog set queries.
The daily sweep stays as the backstop for anything the event misses.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



16
17
18
19
20
21
22
# File 'app/subscribers/listing_issues/retailer_probe_completed_handler.rb', line 16

def perform(event)
  catalog_item = CatalogItem.find_by(id: event.data[:catalog_item_id])
  return unless catalog_item

  adapter = RetailerProbeAdapter.new(item_ids: [catalog_item.id])
  Sync.new(adapter).reconcile_item(catalog_item)
end