From 169dfb26becafc4c1dcf83afed2591a9ceed37ba Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 18 Dec 2018 18:52:35 +0100 Subject: [PATCH] don't show admin account in members api --- app/models/concerns/indexable.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 1ab3b95a3..3dc06de11 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -141,7 +141,13 @@ def query(query, options={}) must << { term: { region: options[:region].upcase }} if options[:region].present? must << { term: { organization_type: options[:organization_type] }} if options[:organization_type].present? must << { term: { focus_area: options[:focus_area] }} if options[:focus_area].present? - must << { term: { role_name: "ROLE_ALLOCATOR" }} unless options[:all_members] + + if options[:all_members] + must << { terms: { role_name: %w(ROLE_ALLOCATOR ROLE_MEMBER) }} + else + must << { term: { role_name: "ROLE_ALLOCATOR" }} + end + must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted] 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?