Skip to content

Commit

Permalink
add views and downloads aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Aug 2, 2019
1 parent 85b4f89 commit 8a9409b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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] = {
Expand Down

0 comments on commit 8a9409b

Please sign in to comment.