Class: Workarea::Search::AdminDiscounts

Inherits:
Object
  • Object
show all
Includes:
AdminIndexSearch, AdminSorting, Pagination, Query
Defined in:
app/queries/workarea/search/admin_discounts.rb

Instance Method Summary collapse

Methods included from Pagination

#each_by, #from, #page, #per_page, #results, #size

Methods included from AdminSorting

available_sorts, #current_sort, #default_admin_sort, #user_selected_sort

Methods included from AdminIndexSearch

#aggregations, #autocomplete?, #exclude_filter_clause, #fields, #filters, #jump_to_navigation_filter_clause, #post_filter, #query, #sanitized_query

Methods included from Query

#additional_options, #aggregations, #body, #id, #load_model_from, #loaded_results, #post_filter, #query, #query_string, #response, #results, #scroll, #stats, #total

Constructor Details

#initialize(params = {}) ⇒ AdminDiscounts

Returns a new instance of AdminDiscounts.



11
12
13
# File 'app/queries/workarea/search/admin_discounts.rb', line 11

def initialize(params = {})
  super(params.merge(type: 'discount'))
end

Instance Method Details

#facetsObject



15
16
17
# File 'app/queries/workarea/search/admin_discounts.rb', line 15

def facets
  super + [TermsFacet.new(self, 'discount_type')]
end

#sortObject



19
20
21
22
23
24
25
26
27
# File 'app/queries/workarea/search/admin_discounts.rb', line 19

def sort
  result = super || []

  if params[:sort] == Sort.redemptions.to_s
    result.prepend(Sort.redemptions.field => Sort.redemptions.direction)
  end

  result
end