Class: SpreeCmCommissioner::Routes::FindPopular
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Routes::FindPopular
- Defined in:
- app/finders/spree_cm_commissioner/routes/find_popular.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(vendor: nil, tenant: nil, route_type: nil, limit: 20) ⇒ FindPopular
constructor
A new instance of FindPopular.
Constructor Details
#initialize(vendor: nil, tenant: nil, route_type: nil, limit: 20) ⇒ FindPopular
Returns a new instance of FindPopular.
10 11 12 13 14 15 |
# File 'app/finders/spree_cm_commissioner/routes/find_popular.rb', line 10 def initialize(vendor: nil, tenant: nil, route_type: nil, limit: 20) @vendor = vendor @tenant = tenant @route_type = route_type @limit = limit.to_i end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/finders/spree_cm_commissioner/routes/find_popular.rb', line 17 def execute scope = SpreeCmCommissioner::Route.includes(:origin_place, :destination_place, :route_photos) scope = scope.where(vendor_id: vendor.id) if vendor.present? scope = scope.where(tenant_id: tenant.id) if tenant.present? scope = scope.where(route_type: route_type.to_s) if route_type.present? scope.order(fulfilled_order_count: :desc, order_count: :desc).limit(limit) end |