Skip to content

Commit

Permalink
aggregations for link-check-status-code. datacite/datacite#540
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 18, 2018
1 parent da69198 commit c545ddd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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] = {
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
1 change: 1 addition & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c545ddd

Please sign in to comment.