diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index 62c42372d..731b29d12 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -148,6 +148,20 @@ def facet_citations_by_year(hash) "years" => arr } end + def facet_citations_by_year_v1(hash) + arr = hash.dig('years', 'buckets').map do |h| + year = h["key_as_string"][0..3].to_i + title = h["key_as_string"][0..3] + + { + 'id' => year, + 'title' => title, + 'sum' => h.dig('total_by_year', 'value') } + end + { "count" => hash.dig("sum_distribution", "value"), + "years" => arr } + end + def facet_counts_by_year_month(hash) arr = hash.dig('year_months', 'buckets').map do |h| month = h["key_as_string"][5..6].to_i diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 879c54b11..6a5190db2 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -125,7 +125,7 @@ def index pairings = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_pairings(response.response.aggregations.pairings.buckets) : nil dois = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_dois(response.response.aggregations.dois.buckets) : nil dois_usage = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_by_dois(response.response.aggregations.dois_usage.dois.buckets) : nil - dois_citations = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_citations_by_year(response.response.aggregations.dois_citations) : nil + dois_citations = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_citations_by_year_v1(response.response.aggregations.dois_citations) : nil citations_histogram = total.positive? && aggregations.include?("metrics_aggregations") ? facet_citations_by_year(response.response.aggregations.citations_histogram) : nil citations = total.positive? && aggregations.include?("metrics_aggregations") ? facet_citations_by_dois(response.response.aggregations.citations.dois.buckets) : nil views_histogram = total.positive? && aggregations.include?("metrics_aggregations") ? facet_counts_by_year_month(response.response.aggregations.views_histogram) : nil