-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Fenner
committed
Apr 12, 2020
1 parent
fa39b92
commit 3ba2d44
Showing
55 changed files
with
7,001 additions
and
2,421 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookChapterConnectionType < BaseConnection | ||
edge_type(BookChapterEdgeType) | ||
field_class GraphQL::Cache::Field | ||
|
||
field :total_count, Integer, null: false, cache: true | ||
field :years, [FacetType], null: true, cache: true | ||
field :registration_agencies, [FacetType], null: true, cache: true | ||
field :repositories, [FacetType], null: true, cache: true | ||
field :affiliations, [FacetType], null: true, cache: true | ||
|
||
def total_count | ||
args = prepare_args(object.arguments) | ||
|
||
response(args).results.total | ||
end | ||
|
||
def years | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_year(res.response.aggregations.years.buckets) : [] | ||
end | ||
|
||
def registration_agencies | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_software(res.response.aggregations.registration_agencies.buckets) : [] | ||
end | ||
|
||
def repositories | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_client(res.response.aggregations.clients.buckets) : [] | ||
end | ||
|
||
def affiliations | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_affiliation(res.response.aggregations.affiliations.buckets) : [] | ||
end | ||
|
||
def response(**args) | ||
Doi.query(args[:query], | ||
ids: args[:ids], | ||
user_id: args[:user_id], | ||
client_id: args[:repository_id], | ||
provider_id: args[:member_id], | ||
funder_id: args[:funder_id], | ||
affiliation_id: args[:affiliation_id], | ||
re3data_id: args[:re3data_id], | ||
year: args[:year], | ||
resource_type_id: "Text", | ||
resource_type: "BookChapter", | ||
has_person: args[:has_person], | ||
has_funder: args[:has_funder], | ||
has_organization: args[:has_organization], | ||
has_citations: args[:has_citations], | ||
has_parts: args[:has_parts], | ||
has_versions: args[:has_versions], | ||
has_views: args[:has_views], | ||
has_downloads: args[:has_downloads], | ||
page: { number: 1, size: 0 }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookChapterEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(BookChapterType) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookChapterType < BaseObject | ||
implements DoiItem | ||
|
||
def type | ||
"BookChapter" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(BookType) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookType < BaseObject | ||
implements DoiItem | ||
|
||
def type | ||
"Book" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
class ConferencePaperConnectionType < BaseConnection | ||
edge_type(ConferencePaperEdgeType) | ||
field_class GraphQL::Cache::Field | ||
|
||
field :total_count, Integer, null: false, cache: true | ||
field :years, [FacetType], null: true, cache: true | ||
field :registration_agencies, [FacetType], null: true, cache: true | ||
field :repositories, [FacetType], null: true, cache: true | ||
field :affiliations, [FacetType], null: true, cache: true | ||
|
||
def total_count | ||
args = prepare_args(object.arguments) | ||
|
||
response(args).results.total | ||
end | ||
|
||
def years | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_year(res.response.aggregations.years.buckets) : [] | ||
end | ||
|
||
def registration_agencies | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_software(res.response.aggregations.registration_agencies.buckets) : [] | ||
end | ||
|
||
def repositories | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_client(res.response.aggregations.clients.buckets) : [] | ||
end | ||
|
||
def affiliations | ||
args = prepare_args(object.arguments) | ||
|
||
res = response(args) | ||
res.results.total.positive? ? facet_by_affiliation(res.response.aggregations.affiliations.buckets) : [] | ||
end | ||
|
||
def response(**args) | ||
Doi.query(args[:query], | ||
ids: args[:ids], | ||
user_id: args[:user_id], | ||
client_id: args[:repository_id], | ||
provider_id: args[:member_id], | ||
funder_id: args[:funder_id], | ||
affiliation_id: args[:affiliation_id], | ||
re3data_id: args[:re3data_id], | ||
year: args[:year], | ||
resource_type_id: "Text", | ||
resource_type: "\"Conference paper\"", | ||
has_person: args[:has_person], | ||
has_funder: args[:has_funder], | ||
has_organization: args[:has_organization], | ||
has_citations: args[:has_citations], | ||
has_parts: args[:has_parts], | ||
has_versions: args[:has_versions], | ||
has_views: args[:has_views], | ||
has_downloads: args[:has_downloads], | ||
page: { number: 1, size: 0 }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class ConferencePaperEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(ConferencePaperType) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class ConferencePaperType < BaseObject | ||
implements DoiItem | ||
|
||
def type | ||
"ConferencePaper" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.