Class: Workarea::Admin::Reports::SalesByCategoryViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Admin::Reports::SalesByCategoryViewModel
- Defined in:
- app/view_models/workarea/admin/reports/sales_by_category_view_model.rb
Instance Method Summary collapse
Instance Method Details
#categories ⇒ Object
11 12 13 |
# File 'app/view_models/workarea/admin/reports/sales_by_category_view_model.rb', line 11 def categories @categories ||= Catalog::Category.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_category_view_model.rb', line 5 def results @results ||= model.results.map do |result| OpenStruct.new({ category: categories[result['_id']] }.merge(result)) end end |