Class: Api::Partner::TicketGroupFilter

Inherits:
Object
  • Object
show all
Defined in:
app/filters/api/partner/ticket_group_filter.rb

Overview

Responsible to filter reservations data dashboard

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collections = nil) ⇒ TicketGroupFilter

Returns a new instance of TicketGroupFilter.

Parameters:

  • collections (Reservation) (defaults to: nil)

    Reservation relations



9
10
11
12
# File 'app/filters/api/partner/ticket_group_filter.rb', line 9

def initialize(collections = nil)
  self.collections = collections unless collections.nil?
  @config = {}
end

Instance Attribute Details

#collectionsObject

Returns the value of attribute collections.



6
7
8
# File 'app/filters/api/partner/ticket_group_filter.rb', line 6

def collections
  @collections
end

#error_messageObject

Returns the value of attribute error_message.



6
7
8
# File 'app/filters/api/partner/ticket_group_filter.rb', line 6

def error_message
  @error_message
end

Instance Method Details

#build_collectionsObject

get desired reservations from database



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/filters/api/partner/ticket_group_filter.rb', line 24

def build_collections
  if filter_params
    _filter_by_voucher_id
    _filter_by_voucher_name
    _filter_by_voucher_price
    _filter_by_quantity
    _filter_by_package_type
    _filter_by_selling_date_range
    _filter_by_valid_date_range
    _filter_by_selling_date
    _filter_by_valid_date
  end
  _order_by
  collections.group(:id)
end

#filter(filter_par) ⇒ Object



15
16
17
18
# File 'app/filters/api/partner/ticket_group_filter.rb', line 15

def filter(filter_par)
  return unless filter_par.present?
  config[:filter] = filter_par
end

#order_by(order) ⇒ Object



20
21
22
# File 'app/filters/api/partner/ticket_group_filter.rb', line 20

def order_by(order)
  config[:order_by] = order
end

#to_collectionsObject



40
41
42
# File 'app/filters/api/partner/ticket_group_filter.rb', line 40

def to_collections
  build_collections.order(created_at: :desc)
end