Class: Workarea::Search::AdminReleases

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pagination

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

Methods included from AdminSorting

#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 = {}) ⇒ AdminReleases

Returns a new instance of AdminReleases.



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

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

Class Method Details

.available_sortsObject



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

def self.available_sorts
  Sort::Collection.new(Sort.published_date)
end

Instance Method Details

#facetsObject



19
20
21
# File 'app/queries/workarea/search/admin_releases.rb', line 19

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

#sortObject



23
24
25
26
27
28
29
30
31
32
# File 'app/queries/workarea/search/admin_releases.rb', line 23

def sort
  Array.wrap(super).tap do |sort|
    current_sort =
      self.class.available_sorts.detect { |s| s.to_s == params[:sort] }

    if current_sort.present? && current_sort.field.present?
      sort.prepend(current_sort.field => current_sort.direction)
    end
  end
end