Class: ListingIssues::WebsiteAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- ListingIssues::WebsiteAdapter
- Defined in:
- app/services/listing_issues/website_adapter.rb
Overview
Website (our own storefront) listing issues. Unlike the marketplace adapters
these aren't reported by an external channel — WE are the channel, so the
signal is derived entirely from our own data: an item that belongs to a
variant group but is missing a value for one of that group's variant axes.
On the website the axis tokens ARE the variant picker (Item#item_grouping_info
groups the family; the picker lets a shopper choose along each axis, e.g.
Voltage then Size). A blank axis value renders an unpickable / blank option on
the live PDP — a self-evident breakage of our own listing we can verify from
our own data, so it's an error.
Scope is the main storefront catalogs (US + CA). Reads stored data only
(rendered_product_specifications + the family's axis_tokens); never calls
out. Mirrors the marketplace adapters; registered in Sync.adapters.
Constant Summary collapse
- PROVIDER =
Provider key stamped on issues produced by this adapter.
'website'- CATALOG_IDS =
Storefront catalogs this check covers — our own US + CA websites. EU (125)
can be added once its families carry axes. [CatalogConstants::US_CATALOG_ID, CatalogConstants::CA_CATALOG_ID].freeze
Instance Method Summary collapse
- #candidate_item_ids ⇒ Array<Integer>
-
#eager_load ⇒ Array
Associations the bulk sweep eager-loads before #issues_for.
- #issues_for(catalog_item) ⇒ Array<ListingIssues::Issue>
- #provider ⇒ String
Instance Method Details
#candidate_item_ids ⇒ Array<Integer>
32 33 34 |
# File 'app/services/listing_issues/website_adapter.rb', line 32 def candidate_item_ids (grouped_catalog_item_ids + open_issue_item_ids).uniq end |
#eager_load ⇒ Array
Returns associations the bulk sweep eager-loads before #issues_for.
63 64 65 |
# File 'app/services/listing_issues/website_adapter.rb', line 63 def eager_load [{ store_item: { item: :variant_groups } }] end |
#issues_for(catalog_item) ⇒ Array<ListingIssues::Issue>
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/services/listing_issues/website_adapter.rb', line 38 def issues_for(catalog_item) # Only active storefront listings are actionable; anything else (still # reachable via open_issue_item_ids) returns [] so the sync auto-resolves # stale rows once the item is fixed, discontinued, or leaves the catalog. return [] unless catalog_item.state == 'active' return [] unless CATALOG_IDS.include?(catalog_item.catalog_id) item = catalog_item.item # The website picker is driven by the DEFAULT family ({Item#item_grouping_info}), # so that's the group whose axes must be complete here. group = item&.variant_group return [] unless group # `axis_tokens` already strips blank entries (the "" the tom_select free-text # picker can leave behind); compact_blank is belt-and-suspenders. axes = group.axis_tokens.compact_blank return [] if axes.empty? missing = axes.reject { |token| item.spec_value(token).present? } return [] if missing.empty? [missing_axis_value_issue(group, axes, missing)] end |
#provider ⇒ String
29 |
# File 'app/services/listing_issues/website_adapter.rb', line 29 def provider = PROVIDER |