diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index 3f133a5f3..435114900 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -98,7 +98,7 @@ def facet_by_key(arr) def facet_by_software(arr) arr.map do |hsh| - { "id" => hsh["key"].downcase, + { "id" => hsh["key"].parameterize(separator: '_'), "title" => hsh["key"], "count" => hsh["doc_count"] } end diff --git a/app/graphql/types/base_connection.rb b/app/graphql/types/base_connection.rb index 7da36b096..22be9ad17 100644 --- a/app/graphql/types/base_connection.rb +++ b/app/graphql/types/base_connection.rb @@ -47,7 +47,7 @@ def facet_by_resource_type(arr) def facet_by_software(arr) arr.map do |hsh| - { "id" => hsh["key"].downcase, + { "id" => hsh["key"].parameterize(separator: '_'), "title" => hsh["key"], "count" => hsh["doc_count"] } end diff --git a/app/graphql/types/service_connection_with_total_type.rb b/app/graphql/types/service_connection_with_total_type.rb index b64ec2c17..00da34f3d 100644 --- a/app/graphql/types/service_connection_with_total_type.rb +++ b/app/graphql/types/service_connection_with_total_type.rb @@ -33,7 +33,7 @@ def affiliations end def pid_entities - object.total_count.positive? ? facet_by_combined_key(object.aggregations.pid_entities.subject.buckets) : [] + object.total_count.positive? ? facet_by_software(object.aggregations.pid_entities.subject.buckets) : [] end def fields_of_science diff --git a/app/models/doi.rb b/app/models/doi.rb index eb7f38105..d7157d111 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -792,11 +792,11 @@ def self.query(query, options={}) filter << { terms: { "subjects.subject": options[:subject].split(",") } } if options[:subject].present? if options[:pid_entity].present? filter << { term: { "subjects.subjectScheme": "PidEntity" } } - filter << { terms: { "subjects.subject": options[:pid_entity].split(",") } } + filter << { terms: { "subjects.subject": options[:pid_entity].split(",").map(&:humanize) } } end if options[:field_of_science].present? filter << { term: { "subjects.subjectScheme": "Fields of Science and Technology (FOS)" } } - filter << { term: { "subjects.subject": "FOS: " + options[:field_of_science].humanize } } + filter << { terms: { "subjects.subject": "FOS: " + options[:field_of_science].split(",").map(&:humanize) } } end filter << { term: { source: options[:source] } } if options[:source].present? filter << { range: { reference_count: { "gte": options[:has_references].to_i } } } if options[:has_references].present? diff --git a/spec/graphql/types/service_type_spec.rb b/spec/graphql/types/service_type_spec.rb index bf7eab1a5..18702611e 100644 --- a/spec/graphql/types/service_type_spec.rb +++ b/spec/graphql/types/service_type_spec.rb @@ -33,7 +33,7 @@ let(:query) do %(query { - services(pidEntity: "Instrument") { + services(pidEntity: "instrument") { totalCount pageInfo { endCursor @@ -80,8 +80,10 @@ response = LupoSchema.execute(query).as_json expect(response.dig("data", "services", "totalCount")).to eq(3) - expect(response.dig("data", "services", "pidEntities")).to eq([{"id"=>"Instrument", "count"=>3}]) - expect(response.dig("data", "services", "fieldsOfScience")).to eq([{"count"=>3, "id"=>"computer_and_information_sciences"}]) + expect(response.dig("data", "services", "pidEntities")).to eq([{"count"=>3, "id"=>"instrument", "title"=>"Instrument"}]) + expect(response.dig("data", "services", "fieldsOfScience")).to eq([{"count"=>3, + "id"=>"computer_and_information_sciences", + "title"=>"Computer and information sciences"}]) expect(Base64.urlsafe_decode64(response.dig("data", "services", "pageInfo", "endCursor")).split(",", 2).last).to eq(services.last.uid) expect(response.dig("data", "services", "pageInfo", "hasNextPage")).to be false expect(response.dig("data", "services", "published")).to eq([{"count"=>3, "id"=>"2011"}])