Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 5, 2020
2 parents 2be12c0 + 6863850 commit 2b061ce
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/facetable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/base_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/service_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
8 changes: 5 additions & 3 deletions spec/graphql/types/service_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

let(:query) do
%(query {
services(pidEntity: "Instrument") {
services(pidEntity: "instrument") {
totalCount
pageInfo {
endCursor
Expand Down Expand Up @@ -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"}])
Expand Down

0 comments on commit 2b061ce

Please sign in to comment.