Class: Workarea::Storefront::UserActivityViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Storefront::UserActivityViewModel
- Defined in:
- app/view_models/workarea/storefront/user_activity_view_model.rb
Instance Method Summary collapse
Instance Method Details
#categories ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/view_models/workarea/storefront/user_activity_view_model.rb', line 18 def categories @categories ||= begin category_ids = model.category_ids.uniq.first(display_count) models = Catalog::Category.any_in(_id: category_ids).to_a category_ids.map do |id| models.detect { |c| c.id.to_s == id.to_s } end.compact end end |
#products ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/view_models/workarea/storefront/user_activity_view_model.rb', line 4 def products @products ||= begin product_ids = model.product_ids.uniq.first(display_count) models = Catalog::Product.any_in(_id: product_ids).to_a models = models.select(&:active?) product_ids.map do |id| product = models.detect { |p| p.id == id } ProductViewModel.wrap(product) if product end.compact end end |
#searches ⇒ Object
30 31 32 |
# File 'app/view_models/workarea/storefront/user_activity_view_model.rb', line 30 def searches model.searches.uniq.first(display_count) end |