Class: Workarea::Admin::Reports::SalesByProductViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Admin::Reports::SalesByProductViewModel
- Defined in:
- app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
Instance Method Summary collapse
Instance Method Details
#products ⇒ Object
11 12 13 |
# File 'app/view_models/workarea/admin/reports/sales_by_product_view_model.rb', line 11 def products @products ||= Catalog::Product.any_in(id: model.results.map { |r| r['_id'] }).to_lookup_hash end |
#results ⇒ Object
5 6 7 8 9 |
# File 'app/view_models/workarea/admin/reports/sales_by_product_view_model.rb', line 5 def results @results ||= model.results.map do |result| OpenStruct.new({ product: products[result['_id']] }.merge(result)) end end |