Skip to content

Commit

Permalink
Replace facet_by_key_raw function with parameter on facet_by_key
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhoads committed Jun 8, 2022
1 parent 56663cc commit 61c75d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions app/graphql/types/base_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,12 @@ def facet_by_year(arr)
end
end

def facet_by_key(arr)
def facet_by_key(arr, title_case: true)
arr.map do |hsh|
title = title_case ? hsh["key"].titleize : hsh["key"]
{
"id" => hsh["key"],
"title" => hsh["key"].titleize,
"count" => hsh["doc_count"],
}
end
end

def facet_by_key_raw(arr)
arr.map do |hsh|
{
"id" => hsh["key"],
"title" => hsh["key"],
"title" => title,
"count" => hsh["doc_count"],
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/repository_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def repository_types
end

def certificates
facet_by_key_raw(object.aggregations.certificates.buckets)
facet_by_key(object.aggregations.certificates.buckets, title_case: false)
end

def members
Expand Down

0 comments on commit 61c75d7

Please sign in to comment.