Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple values in the resource-type-id parameter #1221

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ def self.query(query, options = {})
minimum_should_match = 0

filter << { terms: { doi: options[:ids].map(&:upcase) } } if options[:ids].present?
filter << { term: { resource_type_id: options[:resource_type_id].underscore.dasherize } } if options[:resource_type_id].present?
filter << { terms: { resource_type_id: options[:resource_type_id].split(",").map(&:underscore).map(&:dasherize) } } if options[:resource_type_id].present?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look perfect, can we format it like this,

  if options[:resource_type_id].present?
    resource_type_ids = options[:resource_type_id]
                          .split(",")
                          .map { |id| id.strip.underscore.dasherize }
   filter << { terms: { resource_type_id: resource_type_ids } }
  end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done this, thanks for the suggestion :)

filter << { terms: { "types.resourceType": options[:resource_type].split(",") } } if options[:resource_type].present?
if options[:provider_id].present?
options[:provider_id].split(",").each { |id|
Expand Down