Class: SpreeCmCommissioner::UsersByEventFetcherQuery
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::UsersByEventFetcherQuery
- Defined in:
- app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb
Instance Attribute Summary collapse
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
Instance Method Summary collapse
-
#call ⇒ Object
Fetches distinct users with a completed order containing a line item for the given event(s).
-
#initialize(event_id:) ⇒ UsersByEventFetcherQuery
constructor
A new instance of UsersByEventFetcherQuery.
Constructor Details
#initialize(event_id:) ⇒ UsersByEventFetcherQuery
Returns a new instance of UsersByEventFetcherQuery.
5 6 7 |
# File 'app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb', line 5 def initialize(event_id:) @event_id = event_id end |
Instance Attribute Details
#event_id ⇒ Object (readonly)
Returns the value of attribute event_id.
3 4 5 |
# File 'app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb', line 3 def event_id @event_id end |
Instance Method Details
#call ⇒ Object
Fetches distinct users with a completed order containing a line item for the given event(s)
10 11 12 13 14 15 |
# File 'app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb', line 10 def call Spree::User.joins(orders: :line_items) .where(spree_orders: { state: 'complete' }) .where(spree_line_items: { event_id: @event_id }) .distinct end |