Class: Workarea::ProductReleases

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#productObject (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

#changesetsMongoid::Criteria

All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.

Examples:

Add to the changesets affecting a product in a decorator

def changesets
  super.merge(SomeReleasable.for_product(product.id).changesets_with_children)
end

Returns:



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_skusObject



40
41
42
# File 'app/queries/workarea/product_releases.rb', line 40

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

#releasesObject



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