From 122862cb76ab6f828ab9ddd22cc8e89a5811c74e Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 18 Sep 2018 15:09:19 +0200 Subject: [PATCH] show all members --- app/controllers/members_controller.rb | 8 ++++---- app/models/concerns/indexable.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index f8ce48e0e..1c1774b56 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -26,7 +26,7 @@ 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 @@ -34,7 +34,7 @@ def index 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] = { @@ -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], @@ -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 diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 03b1e0538..75a871248 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -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?