Skip to content

Commit

Permalink
facet for provider non-profit-status. datacite/datacite#807
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 7, 2019
1 parent 83eed42 commit 58c7f18
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def index
member_type: params[:member_type],
organization_type: params[:organization_type],
focus_area: params[:focus_area],
non_profit_status: params[:non_profit_status],
page: page,
sort: sort)
end
Expand All @@ -46,6 +47,7 @@ def index
member_types = total > 0 ? facet_by_key(response.response.aggregations.member_types.buckets) : nil
organization_types = total > 0 ? facet_by_key(response.response.aggregations.organization_types.buckets) : nil
focus_areas = total > 0 ? facet_by_key(response.response.aggregations.focus_areas.buckets) : nil
non_profit_statuses = total > 0 ? facet_by_key(response.response.aggregations.non_profit_statuses.buckets) : nil

@providers = response.results
respond_to do |format|
Expand All @@ -59,7 +61,8 @@ def index
regions: regions,
"memberTypes" => member_types,
"organizationTypes" => organization_types,
"focusAreas" => focus_areas
"focusAreas" => focus_areas,
"nonProfitStatuses" => non_profit_statuses
}.compact

options[:links] = {
Expand All @@ -71,6 +74,7 @@ def index
"member_type" => params[:member_type],
"organization_type" => params[:organization_type],
"focus-area" => params[:focus_area],
"non-profit-status" => params[:non_profit_status],
"page[number]" => page[:number] + 1,
"page[size]" => page[:size],
sort: sort }.compact.to_query
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def query(query, options={})
must << { term: { "consortium_id.raw" => options[:consortium_id] }} if options[:consortium_id].present?
must << { term: { member_type: options[:member_type] }} if options[:member_type].present?
must << { term: { organization_type: options[:organization_type] }} if options[:organization_type].present?
must << { term: { non_profit_status: options[:non_profit_status] }} if options[:non_profit_status].present?
must << { term: { focus_area: options[:focus_area] }} if options[:focus_area].present?

must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted]
Expand Down
3 changes: 2 additions & 1 deletion app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def self.query_aggregations
regions: { terms: { field: 'region', size: 10, min_doc_count: 1 } },
member_types: { terms: { field: 'member_type', size: 10, min_doc_count: 1 } },
organization_types: { terms: { field: 'organization_type', size: 10, min_doc_count: 1 } },
focus_areas: { terms: { field: 'focus_area', size: 10, min_doc_count: 1 } }
focus_areas: { terms: { field: 'focus_area', size: 10, min_doc_count: 1 } },
non_profit_statuses: { terms: { field: 'non_profit_status', size: 10, min_doc_count: 1 } }
}
end

Expand Down

0 comments on commit 58c7f18

Please sign in to comment.