Class: Workarea::Admin::Reports::SalesBySkuViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Admin::Reports::SalesBySkuViewModel
- Defined in:
- app/view_models/workarea/admin/reports/sales_by_sku_view_model.rb
Instance Method Summary collapse
Instance Method Details
#products ⇒ Object
12 13 14 15 16 |
# File 'app/view_models/workarea/admin/reports/sales_by_sku_view_model.rb', line 12 def products @products ||= Catalog::Product.any_in( 'variants.sku' => model.results.map { |r| r['_id'] } ).to_a end |
#results ⇒ Object
5 6 7 8 9 10 |
# File 'app/view_models/workarea/admin/reports/sales_by_sku_view_model.rb', line 5 def results @results ||= model.results.map do |result| product = products.detect { |p| p.skus.include?(result['_id']) } OpenStruct.new({ product: product }.merge(result)) end end |