diff --git a/app/queries/events_query.rb b/app/queries/events_query.rb index 85555bfe3..a31c05aef 100644 --- a/app/queries/events_query.rb +++ b/app/queries/events_query.rb @@ -32,10 +32,10 @@ def citations(doi) end def citations_histogram(doi) - pid = Event.new.normalize_doi(doi) + pid = Event.new.normalize_doi(doi.downcase.split(",").first) query = "(subj_id:\"#{pid}\" AND (relation_type_id:#{PASSIVE_RELATION_TYPES.join(' OR relation_type_id:')})) OR (obj_id:\"#{pid}\" AND (relation_type_id:#{ACTIVE_RELATION_TYPES.join(' OR relation_type_id:')}))" - results = Event.query(query, doi: doi, aggregations: "yearly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets - facet_counts_by_year_month(results) + results = Event.query(query, doi: doi, aggregations: "yearly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram + facet_citations_by_year(results) end @@ -52,8 +52,9 @@ def views(doi) end def views_histogram(doi) + doi = doi.downcase.split(",").first query = "(relation_type_id:unique-dataset-investigations-regular AND source_id:datacite-usage)" - results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets + results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram facet_counts_by_year_month(results) end @@ -70,8 +71,9 @@ def downloads(doi) end def downloads_histogram(doi) + doi = doi.downcase.split(",").first query = "(relation_type_id:unique-dataset-requests-regular AND source_id:datacite-usage)" - results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram.buckets + results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations.histogram facet_counts_by_year_month(results) end