From 597f53517ee762fb2ebc244c2c1fe02d145d44bf Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Fri, 29 Nov 2019 16:59:32 +0100 Subject: [PATCH] remove filter and correct "supplemented" filter --- app/models/event.rb | 13 +++---------- app/queries/events_query.rb | 10 +++++----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index c3ae71373..9e256efb3 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -250,10 +250,7 @@ def self.yearly_histogram_aggregation } { - histogram: { - filter: { script: { script: "true"}}, - aggs: { years: { histogram: { field: "citation_year", interval: 1 , min_doc_count: 1 }, aggs: { "total_by_year" => { sum: { field: "total" } } } }, "sum_distribution" => sum_year_distribution } - }, + years: { histogram: { field: "citation_year", interval: 1 , min_doc_count: 1 }, aggs: { "total_by_year" => { sum: { field: "total" } } } }, "sum_distribution" => sum_year_distribution } end @@ -264,12 +261,8 @@ def self.monthly_histogram_aggregation } } { - histogram: { - filter: { script: { script: "true"}}, - aggs: { - year_months: { date_histogram: { field: "occurred_at", interval: "month", min_doc_count: 1 }, aggs: { "total_by_year_month" => { sum: { field: "total" } } } }, "sum_distribution" => sum_distribution - } - }} + year_months: { date_histogram: { field: "occurred_at", interval: "month", min_doc_count: 1 }, aggs: { "total_by_year_month" => { sum: { field: "total" } } } }, "sum_distribution" => sum_distribution + } end diff --git a/app/queries/events_query.rb b/app/queries/events_query.rb index d0e49ecc2..d9ce825dd 100644 --- a/app/queries/events_query.rb +++ b/app/queries/events_query.rb @@ -5,13 +5,13 @@ class EventsQuery ACTIVE_RELATION_TYPES = [ "cites", - "is-supplement-by", + "is-supplemented-by", "references" ] PASSIVE_RELATION_TYPES = [ "is-cited-by", - "is-supplemented-to", + "is-supplement-to", "is-referenced-by" ] @@ -34,7 +34,7 @@ def citations(doi) def citations_histogram(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 + results = Event.query(query, doi: doi, aggregations: "yearly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations facet_citations_by_year(results) end @@ -54,7 +54,7 @@ def views(doi) 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 + results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations facet_counts_by_year_month(results) end @@ -73,7 +73,7 @@ def downloads(doi) 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 + results = Event.query(query, doi: doi, aggregations: "monthly_histogram_aggregation", page: { size: 1, cursor: [] }).response.aggregations facet_counts_by_year_month(results) end