Class: OnlineMigrations::DataMigrations::PopulateWyImageProfiles
- Inherits:
-
OnlineMigrations::DataMigration
- Object
- OnlineMigrations::DataMigration
- OnlineMigrations::DataMigrations::PopulateWyImageProfiles
- Defined in:
- lib/online_migrations/data_migrations/populate_wy_image_profiles.rb
Overview
Populate WYS (WarmlyYours Site) image profiles using the same logic
as Item::ImageRetriever.
Queries all goods Items (non-publications) and runs ImageRetriever
with tags: 'for-product-page', creating WYS_MAIN, WYS_I01, etc. profiles
from the retrieved images. Skips items that already have WYS_ profiles.
Constant Summary collapse
- BATCH_SIZE =
Batch size.
100- 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
Instance Method Details
#collection ⇒ Object
22 23 24 25 26 |
# File 'lib/online_migrations/data_migrations/populate_wy_image_profiles.rb', line 22 def collection Item.goods.non_publications .where.not(id: ImageProfile.website_image_profiles.select(:item_id)) .in_batches(of: BATCH_SIZE) end |
#count ⇒ Object
36 37 38 |
# File 'lib/online_migrations/data_migrations/populate_wy_image_profiles.rb', line 36 def count Item.goods.non_publications.count end |
#process(items) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/online_migrations/data_migrations/populate_wy_image_profiles.rb', line 28 def process(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 |