From 6bb5520dafb4c36669abc6270ebbcd95c05c9fa6 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 11 Oct 2019 16:04:28 +0200 Subject: [PATCH] rename to software_source_code. #343 --- app/graphql/types/client_type.rb | 4 ++-- .../types/data_catalog_connection_with_meta_type.rb | 5 +++++ app/graphql/types/data_catalog_type.rb | 4 ++-- app/graphql/types/dataset_type.rb | 4 ++-- app/graphql/types/funder_type.rb | 4 ++-- ...b => organization_person_connection_with_meta_type.rb} | 0 app/graphql/types/organization_type.rb | 4 ++-- app/graphql/types/person_type.rb | 4 ++-- app/graphql/types/publication_type.rb | 4 ++-- app/graphql/types/query_type.rb | 8 ++++---- app/graphql/types/software_type.rb | 4 ++-- 11 files changed, 25 insertions(+), 20 deletions(-) rename app/graphql/types/{organization_researcher_connection_with_meta_type.rb => organization_person_connection_with_meta_type.rb} (100%) diff --git a/app/graphql/types/client_type.rb b/app/graphql/types/client_type.rb index ae7bc52f8..080bbf242 100644 --- a/app/graphql/types/client_type.rb +++ b/app/graphql/types/client_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/data_catalog_connection_with_meta_type.rb b/app/graphql/types/data_catalog_connection_with_meta_type.rb index 21dbbe7b8..f780859d4 100644 --- a/app/graphql/types/data_catalog_connection_with_meta_type.rb +++ b/app/graphql/types/data_catalog_connection_with_meta_type.rb @@ -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 diff --git a/app/graphql/types/data_catalog_type.rb b/app/graphql/types/data_catalog_type.rb index 5f1374b20..430d47dcd 100644 --- a/app/graphql/types/data_catalog_type.rb +++ b/app/graphql/types/data_catalog_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/dataset_type.rb b/app/graphql/types/dataset_type.rb index d560defc4..24d08dcd3 100644 --- a/app/graphql/types/dataset_type.rb +++ b/app/graphql/types/dataset_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/funder_type.rb b/app/graphql/types/funder_type.rb index 720f99ef6..d0b0335e4 100644 --- a/app/graphql/types/funder_type.rb +++ b/app/graphql/types/funder_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/organization_researcher_connection_with_meta_type.rb b/app/graphql/types/organization_person_connection_with_meta_type.rb similarity index 100% rename from app/graphql/types/organization_researcher_connection_with_meta_type.rb rename to app/graphql/types/organization_person_connection_with_meta_type.rb diff --git a/app/graphql/types/organization_type.rb b/app/graphql/types/organization_type.rb index 732c647e6..89cbf04d0 100644 --- a/app/graphql/types/organization_type.rb +++ b/app/graphql/types/organization_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/person_type.rb b/app/graphql/types/person_type.rb index 642f0c431..6315c193f 100644 --- a/app/graphql/types/person_type.rb +++ b/app/graphql/types/person_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/publication_type.rb b/app/graphql/types/publication_type.rb index 3aafd88f0..b2a0ee9ef 100644 --- a/app/graphql/types/publication_type.rb +++ b/app/graphql/types/publication_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index fe004de2a..208132a8c 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -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 diff --git a/app/graphql/types/software_type.rb b/app/graphql/types/software_type.rb index e26c5cedd..fea476415 100644 --- a/app/graphql/types/software_type.rb +++ b/app/graphql/types/software_type.rb @@ -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 @@ -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