Class: Api::Dashboard::UpdatedInventoryFilter

Inherits:
Object
  • Object
show all
Defined in:
app/filters/api/dashboard/updated_inventory_filter.rb

Overview

Responsible to filter updated inventories data dashboard

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collections = nil) ⇒ UpdatedInventoryFilter

Returns a new instance of UpdatedInventoryFilter.



8
9
10
11
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 8

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/dashboard/updated_inventory_filter.rb', line 6

def collections
  @collections
end

#error_messageObject

Returns the value of attribute error_message.



6
7
8
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 6

def error_message
  @error_message
end

Instance Method Details

#build_collectionsObject

get desired reservations from database



20
21
22
23
24
25
26
27
28
29
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 20

def build_collections
  if filter_params
    _filter_by_start_date
    _filter_by_end_date
    _filter_by_start_time
    _filter_by_end_time
    _filter_by_date_range
  end
  collections
end

#filter(filter_par) ⇒ Object



14
15
16
17
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 14

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

#to_collectionsObject



31
32
33
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 31

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