Skip to content

Commit

Permalink
use doi query parameter for events index. #261
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 9, 2019
1 parent 4613d85 commit 243be72
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions app/graphql/types/dataset_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ 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

ElasticsearchLoader.for(Doi).load_many(ids)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions app/graphql/types/publication_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ 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

ElasticsearchLoader.for(Doi).load_many(ids)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions app/graphql/types/software_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 243be72

Please sign in to comment.