diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index 5382a6175..7f38cfd07 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -153,6 +153,18 @@ def facet_by_key(arr) end end + def facet_by_bool(arr) + values = { 0 => "no", 1 => "yes" } + + arr.map do |hsh| + { + "id" => hsh["key"] , + "title" => values[hsh["key"]], + "count" => hsh["doc_count"], + } + end + end + def facet_by_software(arr) arr.map do |hsh| { diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index f1a768dd2..be93e981e 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -84,7 +84,7 @@ def index end has_required_contacts = if total > 0 - facet_by_key( + facet_by_bool( response.response.aggregations.has_required_contacts.buckets, ) end diff --git a/app/controllers/v3/providers_controller.rb b/app/controllers/v3/providers_controller.rb index edb78a61c..2115ce804 100644 --- a/app/controllers/v3/providers_controller.rb +++ b/app/controllers/v3/providers_controller.rb @@ -83,7 +83,7 @@ def index end has_required_contacts = if total > 0 - facet_by_key( + facet_by_bool( response.response.aggregations.has_required_contacts.buckets, ) end diff --git a/app/graphql/types/base_connection.rb b/app/graphql/types/base_connection.rb index 3b368df96..1f5f6926d 100644 --- a/app/graphql/types/base_connection.rb +++ b/app/graphql/types/base_connection.rb @@ -89,6 +89,18 @@ def facet_by_key(arr) end end + def facet_by_bool(arr) + values = { 0 => "no", 1 => "yes" } + + arr.map do |hsh| + { + "id" => hsh["key"] , + "title" => values[hsh["key"]], + "count" => hsh["doc_count"], + } + end + end + def facet_by_resource_type(arr) arr.map do |hsh| { diff --git a/app/graphql/types/member_connection_with_total_type.rb b/app/graphql/types/member_connection_with_total_type.rb index bc8a1777c..d2b7392d4 100644 --- a/app/graphql/types/member_connection_with_total_type.rb +++ b/app/graphql/types/member_connection_with_total_type.rb @@ -42,6 +42,6 @@ def non_profit_statuses end def has_required_contacts - facet_by_key(object.aggregations.has_required_contacts.buckets) + facet_by_bool(object.aggregations.has_required_contacts.buckets) end end