diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 9a9f5767a..d3832be7d 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -181,6 +181,10 @@ def index if total.positive? facet_by_source(response.response.aggregations.sources.buckets) end + occurred = + if total.positive? + facet_by_source(response.response.aggregations.occurred.buckets) + end prefixes = if total.positive? facet_by_source(response.response.aggregations.prefixes.buckets) @@ -214,6 +218,7 @@ def index page: page[:cursor].nil? && page[:number].present? ? page[:number] : nil, sources: sources, + occurred: occurred, prefixes: prefixes, "citationTypes" => citation_types, "relationTypes" => relation_types, diff --git a/app/models/event.rb b/app/models/event.rb index 5fc8fbe38..30da52ccd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -253,6 +253,8 @@ 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: { date_histogram: { field: "occurred_at", interval: "year", format: "year", 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 }, aggs: {