From 243be72fd126ec72ee43d69823eda13878bdc645 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 9 Jun 2019 10:42:22 +0200 Subject: [PATCH] use doi query parameter for events index. #261 --- .../types/dataset_dataset_connection_with_meta_type.rb | 2 +- .../types/dataset_publication_connection_with_meta_type.rb | 2 +- .../types/dataset_software_connection_with_meta_type.rb | 2 +- app/graphql/types/dataset_type.rb | 6 +++--- .../types/publication_dataset_connection_with_meta_type.rb | 2 +- .../publication_publication_connection_with_meta_type.rb | 2 +- .../types/publication_software_connection_with_meta_type.rb | 2 +- app/graphql/types/publication_type.rb | 6 +++--- .../types/software_dataset_connection_with_meta_type.rb | 2 +- .../types/software_publication_connection_with_meta_type.rb | 2 +- .../types/software_software_connection_with_meta_type.rb | 2 +- app/graphql/types/software_type.rb | 6 +++--- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/graphql/types/dataset_dataset_connection_with_meta_type.rb b/app/graphql/types/dataset_dataset_connection_with_meta_type.rb index 5352fef1d..70de7080a 100644 --- a/app/graphql/types/dataset_dataset_connection_with_meta_type.rb +++ b/app/graphql/types/dataset_dataset_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class DatasetDatasetConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "Dataset-Dataset").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "Dataset-Dataset").results.total end end diff --git a/app/graphql/types/dataset_publication_connection_with_meta_type.rb b/app/graphql/types/dataset_publication_connection_with_meta_type.rb index b08be44d8..b9d404429 100644 --- a/app/graphql/types/dataset_publication_connection_with_meta_type.rb +++ b/app/graphql/types/dataset_publication_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class DatasetPublicationConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "Dataset-ScholarlyArticle").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "Dataset-ScholarlyArticle").results.total end end diff --git a/app/graphql/types/dataset_software_connection_with_meta_type.rb b/app/graphql/types/dataset_software_connection_with_meta_type.rb index 20ca00ee7..03d251ab9 100644 --- a/app/graphql/types/dataset_software_connection_with_meta_type.rb +++ b/app/graphql/types/dataset_software_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class DatasetSoftwareConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "Dataset-SoftwareSourceCode").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "Dataset-SoftwareSourceCode").results.total end end diff --git a/app/graphql/types/dataset_type.rb b/app/graphql/types/dataset_type.rb index b087888ba..11c86928a 100644 --- a/app/graphql/types/dataset_type.rb +++ b/app/graphql/types/dataset_type.rb @@ -25,7 +25,7 @@ def usage_reports(**args) end def datasets(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "Dataset-Dataset").results.to_a.map do |e| + ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "Dataset-Dataset").results.to_a.map do |e| object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id) end @@ -33,14 +33,14 @@ def datasets(**args) end def publications(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "Dataset-ScholarlyArticle").results.to_a.map do |e| + ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "Dataset-ScholarlyArticle").results.to_a.map do |e| object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id) end ElasticsearchLoader.for(Doi).load_many(ids) end def softwares(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "Dataset-SoftwareSourceCode").results.to_a.map do |e| + 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 ElasticsearchLoader.for(Doi).load_many(ids) diff --git a/app/graphql/types/publication_dataset_connection_with_meta_type.rb b/app/graphql/types/publication_dataset_connection_with_meta_type.rb index a5a561597..99a53e659 100644 --- a/app/graphql/types/publication_dataset_connection_with_meta_type.rb +++ b/app/graphql/types/publication_dataset_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class PublicationDatasetConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "Dataset-ScholarlyArticle").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "Dataset-ScholarlyArticle").results.total end end diff --git a/app/graphql/types/publication_publication_connection_with_meta_type.rb b/app/graphql/types/publication_publication_connection_with_meta_type.rb index 3d35e2018..7d6f7286a 100644 --- a/app/graphql/types/publication_publication_connection_with_meta_type.rb +++ b/app/graphql/types/publication_publication_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class PublicationPublicationConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-ScholarlyArticle").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-ScholarlyArticle").results.total end end diff --git a/app/graphql/types/publication_software_connection_with_meta_type.rb b/app/graphql/types/publication_software_connection_with_meta_type.rb index f740c408f..33630de08 100644 --- a/app/graphql/types/publication_software_connection_with_meta_type.rb +++ b/app/graphql/types/publication_software_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class PublicationSoftwareConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.total end end diff --git a/app/graphql/types/publication_type.rb b/app/graphql/types/publication_type.rb index c63938d89..d35b4cc81 100644 --- a/app/graphql/types/publication_type.rb +++ b/app/graphql/types/publication_type.rb @@ -15,7 +15,7 @@ class PublicationType < BaseObject end def datasets(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "Dataset-ScholarlyArticle").results.to_a.map do |e| + ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "Dataset-ScholarlyArticle").results.to_a.map do |e| object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id) end @@ -23,14 +23,14 @@ def datasets(**args) end def publications(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "ScholarlyArticle-ScholarlyArticle").results.to_a.map do |e| + ids = Event.query(nil, doi: doi_from_url(object.identifier), citation_type: "ScholarlyArticle-ScholarlyArticle").results.to_a.map do |e| object.identifier == e.subj_id ? doi_from_url(e.obj_id) : doi_from_url(e.subj_id) end ElasticsearchLoader.for(Doi).load_many(ids) end def softwares(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.to_a.map do |e| + 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 ElasticsearchLoader.for(Doi).load_many(ids) diff --git a/app/graphql/types/software_dataset_connection_with_meta_type.rb b/app/graphql/types/software_dataset_connection_with_meta_type.rb index b6bd14333..2850e3c41 100644 --- a/app/graphql/types/software_dataset_connection_with_meta_type.rb +++ b/app/graphql/types/software_dataset_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class SoftwareDatasetConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "Dataset-SoftwareSourceCode").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "Dataset-SoftwareSourceCode").results.total end end diff --git a/app/graphql/types/software_publication_connection_with_meta_type.rb b/app/graphql/types/software_publication_connection_with_meta_type.rb index 1f0e689c6..7e114da44 100644 --- a/app/graphql/types/software_publication_connection_with_meta_type.rb +++ b/app/graphql/types/software_publication_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class SoftwarePublicationConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.total end end diff --git a/app/graphql/types/software_software_connection_with_meta_type.rb b/app/graphql/types/software_software_connection_with_meta_type.rb index 0860809c6..90231806a 100644 --- a/app/graphql/types/software_software_connection_with_meta_type.rb +++ b/app/graphql/types/software_software_connection_with_meta_type.rb @@ -7,6 +7,6 @@ class SoftwareSoftwareConnectionWithMetaType < BaseConnection field :total_count, Integer, null: false, cache: true def total_count - Event.query(nil, doi_id: doi_from_url(object.parent.identifier), citation_type: "SoftwareSourceCode-SoftwareSourceCode").results.total + Event.query(nil, doi: doi_from_url(object.parent.identifier), citation_type: "SoftwareSourceCode-SoftwareSourceCode").results.total end end diff --git a/app/graphql/types/software_type.rb b/app/graphql/types/software_type.rb index 036c1a726..2b9fb82e0 100644 --- a/app/graphql/types/software_type.rb +++ b/app/graphql/types/software_type.rb @@ -15,21 +15,21 @@ class SoftwareType < BaseObject end def datasets(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "Dataset-SoftwareSourceCode").results.to_a.map do |e| + 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 ElasticsearchLoader.for(Doi).load_many(ids) end def publications(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "ScholarlyArticle-SoftwareSourceCode").results.to_a.map do |e| + 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 ElasticsearchLoader.for(Doi).load_many(ids) end def softwares(**args) - ids = Event.query(nil, doi_id: doi_from_url(object.identifier), citation_type: "SoftwareSourceCode-SoftwareSourceCode").results.to_a.map do |e| + 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 ElasticsearchLoader.for(Doi).load_many(ids)