Sha256: 63991f7449f4b194de9376414705d54e77c711a8212c128bf6499406bcdcfa24
Contents?: true
Size: 654 Bytes
Versions: 1
Compression:
Stored size: 654 Bytes
Contents
# frozen_string_literal: true # This migration comes from solidus_reviews (originally 20120123141326) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_reviews-1.4.1 | spec/dummy/db/migrate/20200810122155_recalculate_ratings.solidus_reviews.rb |