Skip to content

Commit

Permalink
only show metrics in meta if count > 0. #390
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 2, 2020
1 parent ee4a10f commit 729abb5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/controllers/concerns/facetable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ def facet_by_year(arr)
end

def metric_facet_by_year(arr)
arr.map do |hsh|
{ "id" => hsh["key_as_string"][0..3],
"title" => hsh["key_as_string"][0..3],
"count" => hsh.dig("metric_count", "value").to_i }
arr.reduce([]) do |sum, hsh|
if hsh.dig("metric_count", "value").to_i > 0
sum << {
"id" => hsh["key_as_string"][0..3],
"title" => hsh["key_as_string"][0..3],
"count" => hsh.dig("metric_count", "value").to_i
}
end

sum
end
end

Expand Down

0 comments on commit 729abb5

Please sign in to comment.