Class: Workarea::ProductReleases
- Inherits:
-
Object
- Object
- Workarea::ProductReleases
- Defined in:
- app/queries/workarea/product_releases.rb
Overview
TODO remove in v3.6
This is no longer used, this logic was moved into the search models to allow it to be used for any model (not just products).
Instance Attribute Summary collapse
-
#product ⇒ Object
readonly
Returns the value of attribute product.
Instance Method Summary collapse
-
#changesets ⇒ Mongoid::Criteria
All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.
-
#initialize(product) ⇒ ProductReleases
constructor
A new instance of ProductReleases.
- #pricing_skus ⇒ Object
- #releases ⇒ Object
Constructor Details
#initialize(product) ⇒ ProductReleases
Returns a new instance of ProductReleases.
11 12 13 |
# File 'app/queries/workarea/product_releases.rb', line 11 def initialize(product) @product = product end |
Instance Attribute Details
#product ⇒ Object (readonly)
Returns the value of attribute product.
9 10 11 |
# File 'app/queries/workarea/product_releases.rb', line 9 def product @product end |
Instance Method Details
#changesets ⇒ Mongoid::Criteria
All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.
33 34 35 36 37 38 |
# File 'app/queries/workarea/product_releases.rb', line 33 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 |
#pricing_skus ⇒ Object
40 41 42 |
# File 'app/queries/workarea/product_releases.rb', line 40 def pricing_skus Pricing::Sku.in(id: product.skus).to_a end |
#releases ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/queries/workarea/product_releases.rb', line 15 def releases changesets .uniq(&:release) .reject { |cs| cs.release.blank? } .flat_map { |cs| [cs.release] + cs.release.scheduled_after } .uniq end |