Skip to content

Commit

Permalink
allow filtering of dois by citations, views or downloads. #390
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 15, 2020
1 parent 280c2c6 commit 50b210e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def index
resource_type_id: params[:resource_type_id],
schema_version: params[:schema_version],
subject: params[:subject],
has_citations: params[:has_citations],
has_views: params[:has_views],
has_downloads: params[:has_downloads],
link_check_status: params[:link_check_status],
link_check_has_schema_org: params[:link_check_has_schema_org],
link_check_body_has_pid: params[:link_check_body_has_pid],
Expand Down
3 changes: 3 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@ def self.query(query, options={})
must << { term: { schema_version: "http://datacite.org/schema/kernel-#{options[:schema_version]}" }} if options[:schema_version].present?
must << { terms: { "subjects.subject": options[:subject].split(",") }} if options[:subject].present?
must << { term: { source: options[:source] }} if options[:source].present?
must << { term: { citation_count: { "gte": 1 }} if options[:has_citations].present?
must << { term: { view_count: { "gte": 1 }} if options[:has_views].present?
must << { term: { download_count: { "gte": 1 }} if options[:has_downloads].present?
must << { term: { "landing_page.status": options[:link_check_status] }} if options[:link_check_status].present?
must << { exists: { field: "landing_page.checked" }} if options[:link_checked].present?
must << { term: { "landing_page.hasSchemaOrg": options[:link_check_has_schema_org] }} if options[:link_check_has_schema_org].present?
Expand Down

0 comments on commit 50b210e

Please sign in to comment.