Class: SpreeCmCommissioner::GuestSearcherQuery

Inherits:
Object
  • Object
show all
Defined in:
app/queries/spree_cm_commissioner/guest_searcher_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ GuestSearcherQuery

Returns a new instance of GuestSearcherQuery.



5
6
7
# File 'app/queries/spree_cm_commissioner/guest_searcher_query.rb', line 5

def initialize(params)
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/queries/spree_cm_commissioner/guest_searcher_query.rb', line 3

def params
  @params
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/queries/spree_cm_commissioner/guest_searcher_query.rb', line 12

def call
  return SpreeCmCommissioner::Guest.none if event_id.blank?

  # Optional check-in-group scope (see Role#check_in_scoped_product_ids), set by the operator export
  # and the dashboard preview. nil = unrestricted; an array narrows to guests whose ticket's product
  # is in it — an EMPTY array is a real "no tickets" scope and correctly yields no guests.
  if product_ids.nil?
    query
  else
    query.joins(line_item: :variant).where(spree_variants: { product_id: product_ids })
  end
end

#event_idObject



9
# File 'app/queries/spree_cm_commissioner/guest_searcher_query.rb', line 9

def event_id = params[:event_id]

#product_idsObject



10
# File 'app/queries/spree_cm_commissioner/guest_searcher_query.rb', line 10

def product_ids = params[:product_ids]