Sha256: 633b00078d7ba397fb3d645b5ac10a470d166df2fbd199c3617e5b987c10db88

Contents?: true

Size: 452 Bytes

Versions: 28

Compression:

Stored size: 452 Bytes

Contents

module Workarea
  module Admin
    module Reports
      class SalesByProductViewModel < ApplicationViewModel
        def results
          @results ||= model.results.map do |result|
            OpenStruct.new({ product: products[result['_id']] }.merge(result))
          end
        end

        def products
          @products ||= Catalog::Product.any_in(id: model.results.map { |r| r['_id'] }).to_lookup_hash
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.26 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.25 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.23 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.22 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.21 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.20 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.19 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.18 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.17 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.16 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.15 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.14 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.13 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.12 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.11 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.10 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.9 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.8 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb
workarea-admin-3.5.7 app/view_models/workarea/admin/reports/sales_by_product_view_model.rb