From c545dddc310bda41c9f314c42743fa924c640d15 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 18 Oct 2018 22:31:52 +0200 Subject: [PATCH] aggregations for link-check-status-code. datacite/datacite#540 --- app/controllers/dois_controller.rb | 5 ++++- app/models/concerns/indexable.rb | 1 + app/models/doi.rb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index b41c49ee5..caa78d078 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -44,6 +44,7 @@ def index person_id: params[:person_id], resource_type_id: params[:resource_type_id], schema_version: params[:schema_version], + link_check_status: params[:link_check_status], source: params[:source], page: page, sort: sort) @@ -62,6 +63,7 @@ def index prefixes = total > 0 ? facet_by_key(response.response.aggregations.prefixes.buckets) : nil schema_versions = total > 0 ? facet_by_schema(response.response.aggregations.schema_versions.buckets) : nil sources = total > 0 ? facet_by_key(response.response.aggregations.sources.buckets) : nil + link_checks = total > 0 ? facet_by_cumuative_year(response.response.aggregations.link_checks.buckets) : nil @dois = response.results.results @@ -79,7 +81,8 @@ def index clients: clients, prefixes: prefixes, "schema-versions" => schema_versions, - sources: sources + sources: sources, + link_checks: link_checks }.compact options[:links] = { diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 3610af70e..23fda7f7d 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -123,6 +123,7 @@ def query(query, options={}) must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present? must << { term: { schema_version: "http://datacite.org/schema/kernel-#{options[:schema_version]}" }} if options[:schema_version].present? must << { term: { source: options[:source] }} if options[:source].present? + must << { term: { last_landing_page_status: options[:link_check_status] }} if options[:link_check_status].present? must_not = [] diff --git a/app/models/doi.rb b/app/models/doi.rb index 59ff66c55..5df418da3 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -205,6 +205,7 @@ def self.query_aggregations clients: { terms: { field: 'client_id', size: 25, min_doc_count: 1 } }, prefixes: { terms: { field: 'prefix', size: 10, min_doc_count: 1 } }, schema_versions: { terms: { field: 'schema_version', size: 10, min_doc_count: 1 } }, + link_checks: { terms: { field: 'last_landing_page_status', size: 10, min_doc_count: 1 } }, sources: { terms: { field: 'source', size: 10, min_doc_count: 1 } } } end