Skip to content

Commit

Permalink
add citations, views, downloads #425
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 22, 2020
1 parent 5bd7b26 commit 8c80566
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def dataset(id:)
argument :first, Int, required: false, default_value: 25
end

def publications(query: nil, client_id: nil, provider_id: nil, first: nil)
def publications(query: nil, client_id: nil, provider_id: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil)
Doi.query(query, client_id: client_id, provider_id: provider_id, has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, resource_type_id: "Text", state: "findable", page: { number: 1, size: first }).results.to_a
end

Expand All @@ -214,11 +214,14 @@ def publication(id:)

field :audiovisuals, [AudiovisualType], null: false do
argument :query, String, required: false
argument :has_citations, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :first, Int, required: false, default_value: 25
end

def audiovisuals(query: nil, first: nil)
Doi.query(query, resource_type_id: "Audiovisual", state: "findable", page: { number: 1, size: first }).results.to_a
def audiovisuals(query: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil)
Doi.query(query, resource_type_id: "Audiovisual", state: "findable", has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, page: { number: 1, size: first }).results.to_a
end

field :audiovisual, AudiovisualType, null: false do
Expand Down Expand Up @@ -299,11 +302,14 @@ def image(id:)

field :interactive_resources, [InteractiveResourceType], null: false do
argument :query, String, required: false
argument :has_citations, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :first, Int, required: false, default_value: 25
end

def interactive_resources(query: nil, first: nil)
Doi.query(query, resource_type_id: "InteractiveResource", state: "findable", page: { number: 1, size: first }).results.to_a
def interactive_resources(query: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil)
Doi.query(query, resource_type_id: "InteractiveResource", state: "findable", has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, page: { number: 1, size: first }).results.to_a
end

field :interactive_resource, InteractiveResourceType, null: false do
Expand Down Expand Up @@ -333,11 +339,14 @@ def model(id:)

field :physical_objects, [PhysicalObjectType], null: false do
argument :query, String, required: false
argument :has_citations, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :first, Int, required: false, default_value: 25
end

def physical_objects(query: nil, first: nil)
Doi.query(query, resource_type_id: "PhysicalObject", state: "findable", page: { number: 1, size: first }).results.to_a
def physical_objects(query: nil, has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, first: nil)
Doi.query(query, resource_type_id: "PhysicalObject", state: "findable", has_citations: nil, has_views: nil, has_downloads: nil, page: { number: 1, size: first }).results.to_a
end

field :physical_object, PhysicalObjectType, null: false do
Expand Down Expand Up @@ -377,7 +386,7 @@ def service(id:)
argument :first, Int, required: false, default_value: 25
end

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

Expand Down

0 comments on commit 8c80566

Please sign in to comment.