Class: Maintenance::WwwFamilyBackfill
- Inherits:
-
Object
- Object
- Maintenance::WwwFamilyBackfill
- Defined in:
- app/services/maintenance/www_family_backfill.rb
Overview
Materializes the website's path-derived variant families into canonical
VariantGroup rows — the prerequisite for re-pointing the www variant
picker off Item#item_grouping_info's ltree derivation (Phase B of
doc/tasks/202607051428_VARIANT_GROUPING_UNIFICATION.md).
Self-contained by design: it re-implements the legacy derivation (sales
product-line path + product-category path family key, facet-supplied axes
via SQL) so it keeps working after the legacy code and the Facet model are
deleted. The legacy_facets backup tables (renamed from facets*) outlive
the model one release for exactly this backfill's production run.
Slug policy: the group slug is the legacy composite item_group_name
string, so Google/OpenAI feeds emit an UNCHANGED itemGroupId through the
migration.
Overlap policy: if a path-family already has members in ONE existing
default group (Amazon/Wayfair-era), that group adopts the family's
remaining items. Families split across several existing groups are
reported and skipped (manual merge).
Run: Maintenance::WwwFamilyBackfill.new.call (dry run)
Maintenance::WwwFamilyBackfill.new(dry_run: false).call
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#call ⇒ Result
Absorbs every path-derived family, tolerating per-family errors.
-
#initialize(dry_run: true, io: $stdout) ⇒ WwwFamilyBackfill
constructor
A new instance of WwwFamilyBackfill.
Constructor Details
#initialize(dry_run: true, io: $stdout) ⇒ WwwFamilyBackfill
Returns a new instance of WwwFamilyBackfill.
35 36 37 38 |
# File 'app/services/maintenance/www_family_backfill.rb', line 35 def initialize(dry_run: true, io: $stdout) @dry_run = dry_run @io = io end |
Instance Method Details
#call ⇒ Result
Absorbs every path-derived family, tolerating per-family errors.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/maintenance/www_family_backfill.rb', line 43 def call stats = { families: 0, groups_created: 0, groups_adopted: 0, members_added: 0, axes_set: 0, skipped_conflicts: [], errors: [] } families.each_value do |family| stats[:families] += 1 absorb_family(family, stats) rescue StandardError => e stats[:errors] << "#{family[:slug]}: #{e.}" end report(stats) Result.new(**stats) end |