diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 9c72c0f4e..98f1ae7f2 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -181,9 +181,9 @@ def index if total.positive? facet_by_source(response.response.aggregations.sources.buckets) end - occurred = + citation_years = if total.positive? - facet_by_year(response.response.aggregations.occurred.buckets) + facet_by_year(response.response.aggregations.citation_years.buckets) end prefixes = if total.positive? @@ -218,7 +218,7 @@ def index page: page[:cursor].nil? && page[:number].present? ? page[:number] : nil, sources: sources, - occurred: occurred, + citation_years: citation_years, prefixes: prefixes, "citationTypes" => citation_types, "relationTypes" => relation_types, diff --git a/app/controllers/old_events_controller.rb b/app/controllers/old_events_controller.rb index 4e565be96..1a5dae147 100644 --- a/app/controllers/old_events_controller.rb +++ b/app/controllers/old_events_controller.rb @@ -176,9 +176,9 @@ def index if total > 0 facet_by_source(response.aggregations.prefixes.buckets) end - occurred = + citation_years = if total > 0 - facet_by_year(response.aggregations.occurred.buckets) + facet_by_year(response.aggregations.citation_years.buckets) end citation_types = if total > 0 @@ -203,7 +203,7 @@ def index page: page[:cursor].nil? && page[:number].present? ? page[:number] : nil, sources: sources, - occurred: occurred, + citation_years: citation_years, prefixes: prefixes, "citation-types" => citation_types, "relation-types" => relation_types, diff --git a/app/models/event.rb b/app/models/event.rb index 57c7bd1bc..381475411 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -253,15 +253,16 @@ def self.query_aggregations { sources: { terms: { field: "source_id", size: 10, min_doc_count: 1 } }, prefixes: { terms: { field: "prefix", size: 10, min_doc_count: 1 } }, - occurred: { + citation_years: { date_histogram: { - field: "occurred_at", + field: "citation_year", interval: "year", format: "year", - order: { _key: "desc" }, + order: { + _key: "desc", + }, min_doc_count: 1, }, - aggs: { bucket_truncate: { bucket_sort: { size: 10 } } }, }, registrants: { terms: { field: "registrant_id", size: 10, min_doc_count: 1 },