From f1a57be1a549dadb9e1b6c4c353c36c212e050a6 Mon Sep 17 00:00:00 2001 From: kjgarza Date: Thu, 4 Nov 2021 15:03:47 +0100 Subject: [PATCH] added created aggregation its difficult to see if events from crossref or event datacie have been created lated and where the gaps happen. the occured aggregation only focuses on when the events dates were generated but no when they were captured. this aggregation is more useful to identify problems with collection. --- app/controllers/events_controller.rb | 5 +++++ app/models/event.rb | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 5e4b445c3..f549b3484 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -185,6 +185,10 @@ def index if total > 0 facet_by_year(response.aggregations.occurred.buckets) end + created = + if total > 0 + facet_by_year(response.aggregations.created.buckets) + end prefixes = if total.positive? facet_by_key(response.response.aggregations.prefixes.buckets) @@ -219,6 +223,7 @@ def index page[:cursor].nil? && page[:number].present? ? page[:number] : nil, sources: sources, occurred: occurred, + createdAt: created, prefixes: prefixes, "citationTypes" => citation_types, "relationTypes" => relation_types, diff --git a/app/models/event.rb b/app/models/event.rb index 6732a640c..fe1c2af82 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -263,6 +263,16 @@ def self.query_aggregations }, aggs: { bucket_truncate: { bucket_sort: { size: 10 } } }, }, + created: { + date_histogram: { + field: "created_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: {