Sha256: 5309cb9f21f5fb454ba50c111cfc1f99b363f920b80fbcf3220b119c468a9f67

Contents?: true

Size: 508 Bytes

Versions: 28

Compression:

Stored size: 508 Bytes

Contents

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

        def users
          @users ||= User
            .any_in(email: model.results.map { |r| r['_id'] })
            .each_with_object({}) { |u, r| r[u.email] = u }
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.6 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.5 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.4 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.3 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.2 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.1 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.0 app/view_models/workarea/admin/reports/customers_view_model.rb
workarea-admin-3.5.0.beta.1 app/view_models/workarea/admin/reports/customers_view_model.rb