From 8a9409b85de1f5ffc49aa489e8db62ceed915155 Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Fri, 2 Aug 2019 17:14:48 +0200 Subject: [PATCH] add views and downloads aggregations --- app/controllers/events_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 7c20b0f4f..879c54b11 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -128,8 +128,10 @@ def index dois_citations = total.positive? && aggregations.blank? || aggregations.include?("query_aggregations") ? facet_citations_by_year(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) : nil - downloads_histogram = total.positive? && aggregations.include?("metrics_aggregations") ? facet_counts_by_year_month(response.response.aggregations.downloads) : nil + views_histogram = total.positive? && aggregations.include?("metrics_aggregations") ? facet_counts_by_year_month(response.response.aggregations.views_histogram) : nil + downloads_histogram = total.positive? && aggregations.include?("metrics_aggregations") ? facet_counts_by_year_month(response.response.aggregations.downloads_histogram) : nil + views = total.positive? && aggregations.include?("metrics_aggregations") ? facet_by_source(response.response.aggregations.views.dois.buckets) : nil + downloads = total.positive? && aggregations.include?("metrics_aggregations") ? facet_by_source(response.response.aggregations.downloads.dois.buckets) : nil results = response.results @@ -150,7 +152,9 @@ def index "citationsHistogram": citations_histogram, "uniqueCitations": citations, "viewsHistogram": views_histogram, - "downloadsHistogram": downloads_histogram + "views": views, + "downloadsHistogram": downloads_histogram, + "downloads": downloads }.compact options[:links] = {