From d4d91b43a57bf72ac63fbd3e69fd7231ffdb9f6b Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 16 Apr 2021 07:05:42 +0200 Subject: [PATCH] fix bool handling in facets --- app/controllers/concerns/facetable.rb | 6 +++--- app/graphql/types/base_connection.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index 3d7dad315..90f57485a 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -154,11 +154,11 @@ def facet_by_key(arr) end def facet_by_bool(arr) - values = { 0 => "no", 1 => "yes" } + id = hsh["key"] == 1 ? "true" : "false" arr.map do |hsh| { - "id" => hsh["key"], - "title" => values[hsh["key"]], + "id" => id, + "title" => id.capitalize, "count" => hsh["doc_count"], } end diff --git a/app/graphql/types/base_connection.rb b/app/graphql/types/base_connection.rb index 79e191231..abf377a20 100644 --- a/app/graphql/types/base_connection.rb +++ b/app/graphql/types/base_connection.rb @@ -90,11 +90,11 @@ def facet_by_key(arr) end def facet_by_bool(arr) - values = { 0 => "no", 1 => "yes" } + id = hsh["key"] == 1 ? "true" : "false" arr.map do |hsh| { - "id" => hsh["key"], - "title" => values[hsh["key"]], + "id" => id, + "title" => id.capitalize, "count" => hsh["doc_count"], } end