Sha256: 89e2aae05709a65d8c16f425575f45535e2da88ae21ba3b407d84b727f12942b
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
module Workarea module Admin class ReviewsSearchViewModel < SearchViewModel def results @results ||= PagedArray.from( persisted_results.map do |review| ReviewViewModel.new( review, product: products.detect { |p| p.id.to_s == review.product_id.to_s } ) end, model.results.page, model.results.per_page, total ) end def sort if options[:sort] == Sort.highest_rating.to_s Sort.highest_rating.to_s elsif options[:sort] == Sort.lowest_rating.to_s Sort.lowest_rating.to_s else super end end def sorts super + [ Sort.highest_rating.to_a, Sort.lowest_rating.to_a ] end private def products @products ||= ProductViewModel.wrap( Catalog::Product .any_in(id: persisted_results.map(&:product_id)) .map { |product| Admin::ProductViewModel.new(product) } ) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems