Skip to content

Commit

Permalink
rename to software_source_code. #343
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 11, 2019
1 parent 228b22a commit 6bb5520
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/graphql/types/client_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ClientType < BaseObject
argument :first, Int, required: false, default_value: 25
end

field :softwares, ClientSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software managed by the client" do
field :software_source_codes, ClientSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software managed by the client" do
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end
Expand All @@ -46,7 +46,7 @@ def publications(**args)
Doi.query(args[:query], client_id: object.uid, resource_type_id: "Text", page: { number: 1, size: args[:first] }).results.to_a
end

def softwares(**args)
def software_source_codes(**args)
Doi.query(args[:query], client_id: object.uid, resource_type_id: "Software", page: { number: 1, size: args[:first] }).results.to_a
end
end
5 changes: 5 additions & 0 deletions app/graphql/types/data_catalog_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ class DataCatalogConnectionWithMetaType < BaseConnection
field_class GraphQL::Cache::Field

field :total_count, Integer, null: true, cache: true
field :dataset_connection_count, Integer, null: false, cache: true

def total_count
args = object.arguments
DataCatalog.query(args[:query], limit: 0).dig(:meta, "total").to_i
end

def dataset_connection_count
Doi.query("client.re3data_id:*", page: { number: 1, size: 0 }).results.total
end
end
4 changes: 2 additions & 2 deletions app/graphql/types/data_catalog_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DataCatalogType < BaseObject
argument :first, Int, required: false, default_value: 25
end

field :softwares, DataCatalogSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software hosted by the repository" do
field :software_source_codes, DataCatalogSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software hosted by the repository" do
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end
Expand Down Expand Up @@ -85,7 +85,7 @@ def publications(**args)
Doi.query(args[:query], re3data_id: doi_from_url(object[:id]), resource_type_id: "Text", page: { number: 1, size: args[:first] }).results.to_a
end

def softwares(**args)
def software_source_codes(**args)
Doi.query(args[:query], re3data_id: doi_from_url(object[:id]), resource_type_id: "Software", page: { number: 1, size: args[:first] }).results.to_a
end
end
4 changes: 2 additions & 2 deletions app/graphql/types/dataset_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DatasetType < BaseObject
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end
field :softwares, DatasetSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
field :software_source_codes, DatasetSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end

Expand All @@ -40,7 +40,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def softwsoftware_source_codesares(**args)
ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "Dataset-SoftwareSourceCode").results.to_a.map do |e|
object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id)
end
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/funder_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FunderType < BaseObject
argument :first, Int, required: false, default_value: 25
end

field :softwares, FunderSoftwareConnectionWithMetaType, null: false, description: "Funded software", connection: true, max_page_size: 100 do
field :software_source_codes, FunderSoftwareConnectionWithMetaType, null: false, description: "Funded software", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end

Expand Down Expand Up @@ -45,7 +45,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def software_source_codes(**args)
ids = Event.query(nil, obj_id: object[:id], citation_type: "Funder-SoftwareSourceCode").results.to_a.map do |e|
doi_from_url(e.subj_id)
end
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/organization_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OrganizationType < BaseObject
argument :first, Int, required: false, default_value: 25
end

field :softwares, OrganizationSoftwareConnectionWithMetaType, null: false, description: "Software from this organization", connection: true, max_page_size: 1000 do
field :software_source_codes, OrganizationSoftwareConnectionWithMetaType, null: false, description: "Software from this organization", connection: true, max_page_size: 1000 do
argument :first, Int, required: false, default_value: 25
end

Expand Down Expand Up @@ -63,7 +63,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def software_source_codes(**args)
ids = Event.query(nil, obj_id: object.id, citation_type: "Organization-SoftwareSourceCode").results.to_a.map do |e|
doi_from_url(e.subj_id)
end
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/person_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PersonType < BaseObject
argument :first, Int, required: false, default_value: 25
end

field :softwares, PersonSoftwareConnectionWithMetaType, null: true, description: "Authored software", connection: true, max_page_size: 100 do
field :software_source_codes, PersonSoftwareConnectionWithMetaType, null: true, description: "Authored software", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end

Expand All @@ -39,7 +39,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def software_source_codes(**args)
ids = Event.query(nil, obj_id: https_to_http(object[:id]), citation_type: "Person-SoftwareSourceCode").results.to_a.map do |e|
doi_from_url(e.subj_id)
end
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/publication_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PublicationType < BaseObject
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end
field :softwares, PublicationSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
field :software_source_codes, PublicationSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end

Expand All @@ -30,7 +30,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def software_source_codes(**args)
ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.to_a.map do |e|
object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id)
end
Expand Down
8 changes: 4 additions & 4 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,20 @@ def service(id:)
set_doi(id)
end

field :softwares, SoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do
field :software_source_codes, SoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end

def softwares(query: nil, first: nil)
def software_source_codes(query: nil, first: nil)
Doi.query(query, resource_type_id: "Software", state: "findable", page: { number: 1, size: first }).results.to_a
end

field :software, SoftwareType, null: false do
field :software_source_code, SoftwareType, null: false do
argument :id, ID, required: true
end

def software(id:)
def software_source_code(id:)
set_doi(id)
end

Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/software_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SoftwareType < BaseObject
argument :query, String, required: false
argument :first, Int, required: false, default_value: 25
end
field :softwares, SoftwareSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
field :software_source_codes, SoftwareSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do
argument :first, Int, required: false, default_value: 25
end

Expand All @@ -29,7 +29,7 @@ def publications(**args)
ElasticsearchLoader.for(Doi).load_many(ids)
end

def softwares(**args)
def software_source_codes(**args)
ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "SoftwareSourceCode-SoftwareSourceCode").results.to_a.map do |e|
object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id)
end
Expand Down

0 comments on commit 6bb5520

Please sign in to comment.