Class: OnlineMigrations::BackgroundMigrations::PopulateWyImageProfiles
- Inherits:
-
OnlineMigrations::BackgroundMigration
- Object
- OnlineMigrations::BackgroundMigration
- OnlineMigrations::BackgroundMigrations::PopulateWyImageProfiles
- Defined in:
- lib/online_migrations/background_migrations/populate_wy_image_profiles.rb
Overview
Background migration to populate WYS (WarmlyYours Site) image profiles
using the same logic as Item::ImageRetriever
This migration:
- Queries all Items that are goods (non-publications)
- For each item, runs ImageRetriever with tags: 'for-product-page'
- Creates WYS_MAIN, WYS_I01, etc. profiles from the retrieved images
- Skips items that already have WYS_ profiles
Constant Summary collapse
- WYS_IMAGE_TYPES =
WYS image types in order (MAIN first, then I01-I15). WYS_LIFESTYLE is assigned in CRM, not here.
%w[ WYS_MAIN WYS_I01 WYS_I02 WYS_I03 WYS_I04 WYS_I05 WYS_I06 WYS_I07 WYS_I08 WYS_I09 WYS_I10 WYS_I11 WYS_I12 WYS_I13 WYS_I14 WYS_I15 ].freeze
Instance Method Summary collapse
-
#count ⇒ Object
For progress tracking.
- #process_batch(items) ⇒ Object
- #relation ⇒ Object
Instance Method Details
#count ⇒ Object
For progress tracking
37 38 39 |
# File 'lib/online_migrations/background_migrations/populate_wy_image_profiles.rb', line 37 def count Item.goods.non_publications.count end |
#process_batch(items) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/online_migrations/background_migrations/populate_wy_image_profiles.rb', line 28 def process_batch(items) items.each do |item| populate_profiles_for_item(item) rescue StandardError => e Rails.logger.error("PopulateWyImageProfiles: Error processing item #{item.id} (#{item.sku}): #{e.}") end end |
#relation ⇒ Object
22 23 24 25 26 |
# File 'lib/online_migrations/background_migrations/populate_wy_image_profiles.rb', line 22 def relation # Only process goods items that don't already have WYS profiles Item.goods.non_publications .where.not(id: ImageProfile.website_image_profiles.select(:item_id)) end |