From 0e16a8ba24b929aa6936de24c9fa55b8a142fbba Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 10 Oct 2020 08:44:27 +0200 Subject: [PATCH] remove crossref dois from stats-portal datacite/stats-portal#53 --- app/controllers/concerns/facetable.rb | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index abe46157b..ffc4ec887 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -264,18 +264,22 @@ def facet_by_registrants(arr) def providers_totals(arr) providers = Provider.unscoped.where("allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM' , 'ROLE_CONSORTIUM_ORGANIZATION', 'ROLE_ALLOCATOR')").where(deleted_at: nil).pluck(:symbol, :name).to_h - arr.map do |hsh| - { "id" => hsh["key"], - "title" => providers[hsh["key"].upcase], - "count" => hsh["doc_count"], - "temporal" => { - "this_month" => facet_annual(hsh.this_month.buckets), - "this_year" => facet_annual(hsh.this_year.buckets), - "last_year" => facet_annual(hsh.last_year.buckets), - "two_years_ago" => facet_annual(hsh.two_years_ago.buckets) - }, - "states" => facet_by_key(hsh.states.buckets) - } + arr.reduce([]) do |sum, hsh| + if providers[hsh["key"].upcase] + sum << { "id" => hsh["key"], + "title" => providers[hsh["key"].upcase], + "count" => hsh["doc_count"], + "temporal" => { + "this_month" => facet_annual(hsh.this_month.buckets), + "this_year" => facet_annual(hsh.this_year.buckets), + "last_year" => facet_annual(hsh.last_year.buckets), + "two_years_ago" => facet_annual(hsh.two_years_ago.buckets) + }, + "states" => facet_by_key(hsh.states.buckets) + } + end + + sum end end