From 9c37abeede445fa78590f6fa1f35c081a28d3a6b Mon Sep 17 00:00:00 2001 From: Mike Bennett <93522067+digitaldogsbody@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:57:37 +0100 Subject: [PATCH 1/4] Allow multiple values in the resource-type-id parameter --- app/models/doi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 26a9fb176..983cc0e1f 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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? filter << { terms: { "types.resourceType": options[:resource_type].split(",") } } if options[:resource_type].present? if options[:provider_id].present? options[:provider_id].split(",").each { |id| From fcede10972dbabee15cad26c3780f3d8c460ec65 Mon Sep 17 00:00:00 2001 From: Mike Bennett <93522067+digitaldogsbody@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:08:38 +0100 Subject: [PATCH 2/4] Fix incorrect bracket --- app/models/doi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 983cc0e1f..5cb039ec6 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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 << { terms: { resource_type_id: options[:resource_type_id].split(",").map(&:underscore).map(&: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? filter << { terms: { "types.resourceType": options[:resource_type].split(",") } } if options[:resource_type].present? if options[:provider_id].present? options[:provider_id].split(",").each { |id| From 37d64f2782db7363a630948f4f548aadcbe07891 Mon Sep 17 00:00:00 2001 From: Mike Bennett <93522067+digitaldogsbody@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:11:43 +0100 Subject: [PATCH 3/4] Fix incorrect bracket: take 2 --- app/models/doi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 5cb039ec6..78fc0c931 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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 << { terms: { resource_type_id: options[:resource_type_id].split(",").map(&:underscore).map(&: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? filter << { terms: { "types.resourceType": options[:resource_type].split(",") } } if options[:resource_type].present? if options[:provider_id].present? options[:provider_id].split(",").each { |id| From 06baf813d25fe4070f806aa8bf72a0cfc36fadf0 Mon Sep 17 00:00:00 2001 From: Mike Bennett <93522067+digitaldogsbody@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:05:57 +0100 Subject: [PATCH 4/4] Requested code format change --- app/models/doi.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 78fc0c931..96ae126f9 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -962,7 +962,12 @@ def self.query(query, options = {}) minimum_should_match = 0 filter << { terms: { doi: options[:ids].map(&:upcase) } } if options[:ids].present? - filter << { terms: { resource_type_id: options[:resource_type_id].split(",").map(&:underscore).map(&:dasherize) } } if options[:resource_type_id].present? + 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 filter << { terms: { "types.resourceType": options[:resource_type].split(",") } } if options[:resource_type].present? if options[:provider_id].present? options[:provider_id].split(",").each { |id|