Skip to content

Commit

Permalink
show all members
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Sep 18, 2018
1 parent 3813b36 commit 122862c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def index
elsif params[:ids].present?
response = Provider.find_by_ids(params[:ids], page: page, sort: sort)
else
response = Provider.query(params[:query], year: params[:year], region: params[:region], page: page, sort: sort)
response = Provider.query(params[:query], all_members: true, year: params[:year], region: params[:region], page: page, sort: sort)
end

total = response.results.total
total_pages = page[:size] > 0 ? (total.to_f / page[:size]).ceil : 0
years = total > 0 ? facet_by_year(response.response.aggregations.years.buckets) : nil
regions = total > 0 ? facet_by_region(response.response.aggregations.regions.buckets) : nil

@providers = response.results.results
@members = response.results.results

options = {}
options[:meta] = {
Expand All @@ -47,7 +47,7 @@ def index

options[:links] = {
self: request.original_url,
next: @providers.blank? ? nil : request.base_url + "/providers?" + {
next: @members.blank? ? nil : request.base_url + "/members?" + {
query: params[:query],
year: params[:year],
region: params[:region],
Expand All @@ -58,7 +58,7 @@ def index
options[:include] = @include
options[:is_collection] = true

render json: MemberSerializer.new(@providers, options).serialized_json, status: :ok
render json: MemberSerializer.new(@members, options).serialized_json, status: :ok
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def query(query, options={})
if self.name == "Provider"
must << { range: { created: { gte: "#{options[:year].split(",").min}||/y", lte: "#{options[:year].split(",").max}||/y", format: "yyyy" }}} if options[:year].present?
must << { term: { region: options[:region].upcase }} if options[:region].present?
must << { term: { role_name: "ROLE_ALLOCATOR" }}
must << { term: { role_name: "ROLE_ALLOCATOR" }} unless options[:all_members]
must_not << { exists: { field: "deleted_at" }}
elsif self.name == "Client"
must << { range: { created: { gte: "#{options[:year].split(",").min}||/y", lte: "#{options[:year].split(",").max}||/y", format: "yyyy" }}} if options[:year].present?
Expand Down

0 comments on commit 122862c

Please sign in to comment.