Sha256: 28440bdea01209a29ed23ceeee665e3dad77e52f6f87cb0b85476c293cec7224
Contents?: true
Size: 582 Bytes
Versions: 6
Compression:
Stored size: 582 Bytes
Contents
# frozen_string_literal: true class RecalculateRatings < SolidusSupport::Migration[4.2] def up Spree::Product.reset_column_information Spree::Product.update_all reviews_count: 0 Spree::Product.joins(:reviews).where("spree_reviews.id IS NOT NULL").find_each do |p| Spree::Product.update_counters p.id, reviews_count: p.reviews.approved.length # recalculate_product_rating exists on the review, not the product if p.reviews.approved.count > 0 p.reviews.approved.first.recalculate_product_rating end end end def down; end end
Version data entries
6 entries across 6 versions & 1 rubygems