Sha256: 92a6652a7873a8cdaec70de2f7f8008ab1ae7526273dc8dc3371f0028cf4115e

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

module Workarea
  class ProductReleases
    attr_reader :product

    def initialize(product)
      @product = product
    end

    def releases
      Release.schedule_affected_by_changesets(changesets)
    end

    # All {Releasable}s that could affect the product's Elasticsearch document
    # should add their changesets to this method.
    #
    # @example Add to the changesets affecting a product in a decorator
    #   def changesets
    #     super.merge(SomeReleasable.for_product(product.id).changesets_with_children)
    #   end
    #
    # @return [Mongoid::Criteria]
    #
    def changesets
      criteria = product.changesets_with_children
      pricing_skus.each { |ps| criteria.merge!(ps.changesets_with_children) }
      criteria.merge!(FeaturedProducts.changesets(product.id))
      criteria.includes(:release)
    end

    def pricing_skus
      Pricing::Sku.in(id: product.skus).to_a
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/queries/workarea/product_releases.rb
workarea-core-3.5.26 app/queries/workarea/product_releases.rb
workarea-core-3.5.25 app/queries/workarea/product_releases.rb
workarea-core-3.5.23 app/queries/workarea/product_releases.rb
workarea-core-3.5.22 app/queries/workarea/product_releases.rb