From 0ca02f506969d5ae208b71cf5229d20cd2a4e139 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 22 Nov 2019 08:13:52 +0100 Subject: [PATCH] include states. datacite/datacite#359 --- app/controllers/concerns/facetable.rb | 11 ++++++++--- app/models/doi.rb | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index f601bc46a..95c66dd59 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -323,7 +323,8 @@ def providers_totals(arr) { "id" => hsh["key"], "title" => providers[hsh["key"].upcase], "count" => hsh["doc_count"], - "year" => facet_annual(hsh.year.buckets) + "year" => facet_annual(hsh.year.buckets), + "states" => facet_by_key(hsh.states.buckets) # "this_month" => facet_anual(hsh.this_month.buckets), # "this_year" => facet_anual(hsh.this_year.buckets), @@ -339,7 +340,9 @@ def prefixes_totals(arr) { "id" => hsh["key"], "title" => hsh["key"], "count" => hsh["doc_count"], - "year" => facet_annual(hsh.year.buckets) + "year" => facet_annual(hsh.year.buckets), + "states" => facet_by_key(hsh.states.buckets) + # "temporal" => { # "this_month" => facet_anual(hsh.this_month.buckets), # "this_year" => facet_anual(hsh.this_year.buckets), @@ -360,7 +363,9 @@ def clients_totals(arr) { "id" => hsh["key"], "title" => clients[hsh["key"].upcase], "count" => hsh["doc_count"], - "year" => facet_annual(hsh.year.buckets) + "year" => facet_annual(hsh.year.buckets), + "states" => facet_by_key(hsh.states.buckets) + # "temporal" => { # "this_month" => facet_anual(hsh.this_month.buckets), # "this_year" => facet_anual(hsh.this_year.buckets), diff --git a/app/models/doi.rb b/app/models/doi.rb index 6571c8be8..760036819 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -522,7 +522,10 @@ def self.totals_aggregations end def self.sub_aggregations - { year: { date_histogram: { field: "created", interval: "year", format: "yyyy" } } } + { + states: { terms: { field: 'aasm_state', size: 4, min_doc_count: 1 } }, + year: { date_histogram: { field: "created", interval: "year", format: "yyyy" } } + } # { # states: { terms: { field: 'aasm_state', size: 4, min_doc_count: 1 } },