Skip to content

Commit

Permalink
adding occurred facet to events
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 19, 2021
1 parent 7d07b46 commit c509532
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit c509532

Please sign in to comment.