Skip to content

Commit

Permalink
use citation year
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 20, 2021
1 parent be58107 commit 5b4e1b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/old_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 5b4e1b4

Please sign in to comment.