From c28023dd47b5b570854a1a77432251fc6c229e3d Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 4 Apr 2020 18:06:17 +0200 Subject: [PATCH] streamline args for graphql queries --- app/graphql/schema.graphql | 367 +++++++++++++++++- .../types/client_connection_with_meta_type.rb | 8 +- app/graphql/types/client_type.rb | 67 +++- app/graphql/types/doi_item.rb | 12 +- app/graphql/types/funder_type.rb | 45 ++- app/graphql/types/organization_type.rb | 37 +- app/graphql/types/person_type.rb | 44 ++- app/graphql/types/provider_type.rb | 87 ++++- 8 files changed, 599 insertions(+), 68 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 3e828cd9a..d937c315f 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -43,6 +43,8 @@ type Audiovisual implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -141,6 +143,8 @@ type Audiovisual implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -174,6 +178,8 @@ type Audiovisual implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -227,6 +233,8 @@ type Audiovisual implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -310,6 +318,8 @@ type Audiovisual implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -324,6 +334,9 @@ type Audiovisual implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -340,6 +353,8 @@ type Audiovisual implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -398,6 +413,8 @@ type Client { Datasets managed by the client """ datasets( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -408,15 +425,22 @@ type Client { """ before: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int + providerId: String query: String + resourceTypeId: String userId: String ): DatasetConnectionWithMeta @@ -468,6 +492,8 @@ type Client { Publications managed by the client """ publications( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -478,15 +504,22 @@ type Client { """ before: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int + providerId: String query: String + resourceTypeId: String userId: String ): PublicationConnectionWithMeta @@ -504,6 +537,8 @@ type Client { Software managed by the client """ softwares( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -514,15 +549,22 @@ type Client { """ before: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int + providerId: String query: String + resourceTypeId: String userId: String ): SoftwareConnectionWithMeta @@ -550,6 +592,8 @@ type Client { Works managed by the client """ works( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -560,15 +604,22 @@ type Client { """ before: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int + providerId: String query: String + resourceTypeId: String userId: String ): WorkConnectionWithMeta } @@ -678,6 +729,8 @@ type Collection implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -776,6 +829,8 @@ type Collection implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -809,6 +864,8 @@ type Collection implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -862,6 +919,8 @@ type Collection implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -945,6 +1004,8 @@ type Collection implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -959,6 +1020,9 @@ type Collection implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -975,6 +1039,8 @@ type Collection implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1247,6 +1313,8 @@ type DataPaper implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1345,6 +1413,8 @@ type DataPaper implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1378,6 +1448,8 @@ type DataPaper implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1431,6 +1503,8 @@ type DataPaper implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1514,6 +1588,8 @@ type DataPaper implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1528,6 +1604,9 @@ type DataPaper implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -1544,6 +1623,8 @@ type DataPaper implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1594,6 +1675,8 @@ type Dataset implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1692,6 +1775,8 @@ type Dataset implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1725,6 +1810,8 @@ type Dataset implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1778,6 +1865,8 @@ type Dataset implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1882,6 +1971,8 @@ type Dataset implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -1896,6 +1987,9 @@ type Dataset implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -1912,6 +2006,8 @@ type Dataset implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2092,6 +2188,8 @@ interface DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2190,6 +2288,8 @@ interface DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2223,6 +2323,8 @@ interface DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2276,6 +2378,8 @@ interface DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2359,6 +2463,8 @@ interface DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2373,6 +2479,9 @@ interface DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -2389,6 +2498,8 @@ interface DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2439,6 +2550,8 @@ type Event implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2537,6 +2650,8 @@ type Event implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2570,6 +2685,8 @@ type Event implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2623,6 +2740,8 @@ type Event implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2706,6 +2825,8 @@ type Event implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2720,6 +2841,9 @@ type Event implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -2736,6 +2860,8 @@ type Event implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2786,6 +2912,8 @@ type EventData implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2884,6 +3012,8 @@ type EventData implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2917,6 +3047,8 @@ type EventData implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -2970,6 +3102,8 @@ type EventData implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3053,6 +3187,8 @@ type EventData implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3067,6 +3203,9 @@ type EventData implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3083,6 +3222,8 @@ type EventData implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3219,6 +3360,8 @@ type Funder { first: Int = 25 hasCitations: Int hasDownloads: Int + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3263,6 +3406,8 @@ type Funder { first: Int = 25 hasCitations: Int hasDownloads: Int + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3292,6 +3437,8 @@ type Funder { first: Int = 25 hasCitations: Int hasDownloads: Int + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3318,6 +3465,8 @@ type Funder { Funded works """ works( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3331,6 +3480,8 @@ type Funder { first: Int = 25 hasCitations: Int hasDownloads: Int + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3340,6 +3491,7 @@ type Funder { last: Int providerId: String query: String + resourceTypeId: String userId: String ): WorkConnectionWithMeta } @@ -3444,6 +3596,8 @@ type Image implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3542,6 +3696,8 @@ type Image implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3575,6 +3731,8 @@ type Image implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3628,6 +3786,8 @@ type Image implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3711,6 +3871,8 @@ type Image implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3725,6 +3887,9 @@ type Image implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -3741,6 +3906,8 @@ type Image implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3791,6 +3958,8 @@ type InteractiveResource implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3889,6 +4058,8 @@ type InteractiveResource implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3922,6 +4093,8 @@ type InteractiveResource implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -3975,6 +4148,8 @@ type InteractiveResource implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4058,6 +4233,8 @@ type InteractiveResource implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4072,6 +4249,9 @@ type InteractiveResource implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -4088,6 +4268,8 @@ type InteractiveResource implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4138,6 +4320,8 @@ type Model implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4236,6 +4420,8 @@ type Model implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4269,6 +4455,8 @@ type Model implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4322,6 +4510,8 @@ type Model implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4405,6 +4595,8 @@ type Model implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4419,6 +4611,9 @@ type Model implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -4435,6 +4630,8 @@ type Model implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4697,6 +4894,8 @@ type Other implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4795,6 +4994,8 @@ type Other implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4828,6 +5029,8 @@ type Other implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4881,6 +5084,8 @@ type Other implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4964,6 +5169,8 @@ type Other implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -4978,6 +5185,9 @@ type Other implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -4994,6 +5204,8 @@ type Other implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5085,6 +5297,8 @@ type Person { first: Int = 25 hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean hasViews: Int ids: String @@ -5138,6 +5352,8 @@ type Person { first: Int = 25 hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean hasViews: Int ids: String @@ -5166,6 +5382,8 @@ type Person { first: Int = 25 hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean hasViews: Int ids: String @@ -5191,6 +5409,8 @@ type Person { Authored works """ works( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5204,6 +5424,8 @@ type Person { first: Int = 25 hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean hasViews: Int ids: String @@ -5267,6 +5489,8 @@ type PhysicalObject implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5365,6 +5589,8 @@ type PhysicalObject implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5398,6 +5624,8 @@ type PhysicalObject implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5451,6 +5679,8 @@ type PhysicalObject implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5534,6 +5764,8 @@ type PhysicalObject implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5548,6 +5780,9 @@ type PhysicalObject implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -5564,6 +5799,8 @@ type PhysicalObject implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5653,9 +5890,11 @@ type Provider { country: Country """ - Authored datasets + Datasets by this provider. """ datasets( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5667,15 +5906,21 @@ type Provider { before: String clientId: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int query: String + resourceTypeId: String userId: String ): DatasetConnectionWithMeta @@ -5754,9 +5999,11 @@ type Provider { ): ProviderPrefixConnectionWithMeta """ - Authored publications + Publications by this provider. """ publications( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5768,15 +6015,21 @@ type Provider { before: String clientId: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int query: String + resourceTypeId: String userId: String ): PublicationConnectionWithMeta @@ -5791,9 +6044,11 @@ type Provider { rorId: String! """ - Authored software + Software by this provider. """ softwares( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5805,15 +6060,21 @@ type Provider { before: String clientId: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int query: String + resourceTypeId: String userId: String ): SoftwareConnectionWithMeta @@ -5833,9 +6094,11 @@ type Provider { website: String """ - Authored works + Works by this provider. """ works( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -5847,15 +6110,21 @@ type Provider { before: String clientId: String first: Int = 25 + funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int + ids: String """ Returns the last _n_ elements from the list. """ last: Int query: String + resourceTypeId: String userId: String ): WorkConnectionWithMeta } @@ -5964,6 +6233,8 @@ type Publication implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6062,6 +6333,8 @@ type Publication implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6095,6 +6368,8 @@ type Publication implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6148,6 +6423,8 @@ type Publication implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6231,6 +6508,8 @@ type Publication implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6245,6 +6524,9 @@ type Publication implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -6261,6 +6543,8 @@ type Publication implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6766,6 +7050,8 @@ type Service implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6864,6 +7150,8 @@ type Service implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6897,6 +7185,8 @@ type Service implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -6950,6 +7240,8 @@ type Service implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7033,6 +7325,8 @@ type Service implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7047,6 +7341,9 @@ type Service implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -7063,6 +7360,8 @@ type Service implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7150,6 +7449,8 @@ type Software implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7248,6 +7549,8 @@ type Software implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7281,6 +7584,8 @@ type Software implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7334,6 +7639,8 @@ type Software implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7417,6 +7724,8 @@ type Software implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7431,6 +7740,9 @@ type Software implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -7447,6 +7759,8 @@ type Software implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7566,6 +7880,8 @@ type Sound implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7664,6 +7980,8 @@ type Sound implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7697,6 +8015,8 @@ type Sound implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7750,6 +8070,8 @@ type Sound implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7833,6 +8155,8 @@ type Sound implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -7847,6 +8171,9 @@ type Sound implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -7863,6 +8190,8 @@ type Sound implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8091,6 +8420,8 @@ type Work implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8189,6 +8520,8 @@ type Work implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8222,6 +8555,8 @@ type Work implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8275,6 +8610,8 @@ type Work implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8358,6 +8695,8 @@ type Work implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8372,6 +8711,9 @@ type Work implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -8388,6 +8730,8 @@ type Work implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8476,6 +8820,8 @@ type Workflow implements DoiItem { Citations for this DOI. """ citations( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8574,6 +8920,8 @@ type Workflow implements DoiItem { The DOI is a part of this DOI. """ partOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8607,6 +8955,8 @@ type Workflow implements DoiItem { Parts of this DOI. """ parts( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8660,6 +9010,8 @@ type Workflow implements DoiItem { References for this DOI. """ references( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8743,6 +9095,8 @@ type Workflow implements DoiItem { The DOI is a version of this DOI. """ versionOf( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ @@ -8757,6 +9111,9 @@ type Workflow implements DoiItem { funderId: String hasCitations: Int hasDownloads: Int + hasFunder: Boolean + hasOrganization: Boolean + hasPerson: Boolean hasViews: Int ids: String @@ -8773,6 +9130,8 @@ type Workflow implements DoiItem { Versions of this DOI. """ versions( + affiliationId: String + """ Returns the elements in the list that come after the specified cursor. """ diff --git a/app/graphql/types/client_connection_with_meta_type.rb b/app/graphql/types/client_connection_with_meta_type.rb index eeafa1220..da48e7608 100644 --- a/app/graphql/types/client_connection_with_meta_type.rb +++ b/app/graphql/types/client_connection_with_meta_type.rb @@ -17,15 +17,15 @@ def total_count def years args = prepare_args(object.arguments) - res = response(**args) - res.results.total.positive? ? facet_by_year(res.response.aggregations.years.buckets) : nil + r = response(**args) + r.results.total.positive? ? facet_by_year(r.response.aggregations.years.buckets) : nil end def software args = prepare_args(object.arguments) - res = response(**args) - res.results.total.positive? ? facet_by_software(res.response.aggregations.software.buckets) : nil + r = response(**args) + r.results.total.positive? ? facet_by_software(r.response.aggregations.software.buckets) : nil end def response(**args) diff --git a/app/graphql/types/client_type.rb b/app/graphql/types/client_type.rb index 6aadff72e..14716ae89 100644 --- a/app/graphql/types/client_type.rb +++ b/app/graphql/types/client_type.rb @@ -24,7 +24,15 @@ class ClientType < BaseObject field :datasets, DatasetConnectionWithMetaType, null: true, connection: true, description: "Datasets managed by the client" do argument :query, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :provider_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -33,7 +41,15 @@ class ClientType < BaseObject field :publications, PublicationConnectionWithMetaType, null: true, connection: true, description: "Publications managed by the client" do argument :query, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :provider_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -42,7 +58,15 @@ class ClientType < BaseObject field :softwares, SoftwareConnectionWithMetaType, null: true, connection: true, description: "Software managed by the client" do argument :query, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :provider_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -51,7 +75,15 @@ class ClientType < BaseObject field :works, WorkConnectionWithMetaType, null: true, connection: true, description: "Works managed by the client" do argument :query, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :provider_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -70,19 +102,30 @@ def type end def datasets(**args) - Doi.query(args[:query], user_id: args[:user_id].present? ? orcid_from_url(args[:user_id]) : nil, client_id: object.uid, resource_type_id: "Dataset", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Dataset" + r = response(**args) + + r.results.to_a end def publications(**args) - Doi.query(args[:query], user_id: args[:user_id].present? ? orcid_from_url(args[:user_id]) : nil, client_id: object.uid, resource_type_id: "Text", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Text" + r = response(**args) + + r.results.to_a end def softwares(**args) - Doi.query(args[:query], user_id: args[:user_id].present? ? orcid_from_url(args[:user_id]) : nil, client_id: object.uid, resource_type_id: "Software", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Software" + r = response(**args) + + r.results.to_a end def works(**args) - Doi.query(args[:query], user_id: args[:user_id].present? ? orcid_from_url(args[:user_id]) : nil, client_id: object.uid, page: { number: 1, size: args[:first] }).results.to_a + r = response(**args) + + r.results.to_a end def prefixes(**args) @@ -90,18 +133,24 @@ def prefixes(**args) end def view_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.views.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : [] end def download_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.downloads.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : [] end def citation_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.citations.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : [] end - def response - @response ||= Doi.query(nil, client_id: object.uid, state: "findable", page: { number: 1, size: 0 }) + def response(**args) + Doi.query(args[:query], funder_id: args[:funder_id], user_id: args[:user_id], client_id: object.uid, provider_id: args[:provider_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_funder: args[:has_funder], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index 6369bb680..ea1cf6e5d 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -45,6 +45,7 @@ module DoiItem field :citations_over_time, [YearTotalType], null: true, description: "Citations by year." field :views_over_time, [YearMonthTotalType], null: true, description: "Views by month." field :downloads_over_time, [YearMonthTotalType], null: true, description: "Downloads by month." + field :references, WorkConnectionWithMetaType, null: true, connection: true, max_page_size: 100, description: "References for this DOI." do argument :query, String, required: false argument :ids, String, required: false @@ -52,6 +53,7 @@ module DoiItem argument :funder_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false argument :has_person, Boolean, required: false argument :has_funder, Boolean, required: false argument :has_organization, Boolean, required: false @@ -67,6 +69,7 @@ module DoiItem argument :funder_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false argument :has_person, Boolean, required: false argument :has_funder, Boolean, required: false argument :has_organization, Boolean, required: false @@ -82,6 +85,7 @@ module DoiItem argument :funder_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false argument :has_person, Boolean, required: false argument :has_funder, Boolean, required: false argument :has_organization, Boolean, required: false @@ -97,6 +101,7 @@ module DoiItem argument :funder_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false argument :has_person, Boolean, required: false argument :has_funder, Boolean, required: false argument :has_organization, Boolean, required: false @@ -114,6 +119,7 @@ module DoiItem argument :provider_id, String, required: false argument :has_person, Boolean, required: false argument :has_funder, Boolean, required: false + argument :affiliation_id, String, required: false argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false @@ -127,6 +133,10 @@ module DoiItem argument :funder_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_funder, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -219,7 +229,7 @@ def version_of(**args) def response(**args) return [] if args[:ids].blank? - @response ||= Doi.query(args[:query], ids: args[:ids], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + Doi.query(args[:query], ids: args[:ids], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a end def doi_link(url) diff --git a/app/graphql/types/funder_type.rb b/app/graphql/types/funder_type.rb index 511caecf0..2c91724a1 100644 --- a/app/graphql/types/funder_type.rb +++ b/app/graphql/types/funder_type.rb @@ -18,6 +18,8 @@ class FunderType < BaseObject argument :user_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -30,6 +32,8 @@ class FunderType < BaseObject argument :user_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -42,6 +46,8 @@ class FunderType < BaseObject argument :user_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -54,6 +60,10 @@ class FunderType < BaseObject argument :user_id, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -66,34 +76,51 @@ def address end def publications(**args) - Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Text" + r = response(**args) + + r.results.to_a end def datasets(**args) - Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Dataset" + r = response(**args) + + r.results.to_a end def softwares(**args) - Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Software" + r = response(**args) + + r.results.to_a end def works(**args) - Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + r = response(**args) + + r.results.to_a end def view_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.views.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : 0 end def download_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.downloads.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : 0 end def citation_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.citations.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : 0 end - def response - @response ||= Doi.query(nil, funder_id: object[:id], state: "findable", page: { number: 1, size: 0 }) + def response(**args) + Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/organization_type.rb b/app/graphql/types/organization_type.rb index f203e6aa3..ad4e47f5f 100644 --- a/app/graphql/types/organization_type.rb +++ b/app/graphql/types/organization_type.rb @@ -84,36 +84,51 @@ def address end def publications(**args) - Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Text" + r = response(args) + + r.results.to_a end def datasets(**args) - Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Dataset" + r = response(args) + + r.results.to_a end def softwares(**args) - Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Software" + r = response(args) + + r.results.to_a end def works(**args) - Rails.logger.info object[:id] - Rails.logger.info args.inspect - Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + r = response(args) + + r.results.to_a end def view_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.views.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : 0 end def download_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.downloads.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : 0 end def citation_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.citations.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : 0 end - def response - @response ||= Doi.query(nil, affiliation_id: object[:id], state: "findable", page: { number: 1, size: 0 }) + def response(**args) + Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:client_id], provider_id: args[:provider_id], funder_id: args[:funder_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/person_type.rb b/app/graphql/types/person_type.rb index 24851ecf0..24af4e71f 100644 --- a/app/graphql/types/person_type.rb +++ b/app/graphql/types/person_type.rb @@ -17,6 +17,8 @@ class PersonType < BaseObject argument :ids, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_funder, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -28,6 +30,8 @@ class PersonType < BaseObject argument :ids, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_funder, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -39,6 +43,8 @@ class PersonType < BaseObject argument :ids, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :has_funder, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -50,6 +56,9 @@ class PersonType < BaseObject argument :ids, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false + argument :affiliation_id, String, required: false + argument :has_funder, Boolean, required: false + argument :has_organization, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -57,34 +66,51 @@ class PersonType < BaseObject end def publications(**args) - Doi.query(args[:query], user_id: orcid_from_url(object[:id]), client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Text" + r = response(**args) + + r.results.to_a end def datasets(**args) - Doi.query(args[:query], user_id: orcid_from_url(object[:id]), client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Dataset" + r = response(**args) + + r.results.to_a end def softwares(**args) - Doi.query(args[:query], user_id: orcid_from_url(object[:id]), client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + args[:resource_type_id] = "Software" + r = response(**args) + + r.results.to_a end def works(**args) - Doi.query(args[:query], user_id: orcid_from_url(object[:id]), client_id: args[:client_id], provider_id: args[:provider_id], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + r = response(**args) + + r.results.to_a end def view_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.views.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : 0 end def download_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.downloads.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : 0 end def citation_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.citations.buckets) : 0 + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : 0 end - def response - @response ||= Doi.query(nil, user_id: orcid_from_url(object[:id]), state: "findable", page: { number: 1, size: 0 }) + def response(**args) + Doi.query(args[:query], user_id: object[:id], client_id: args[:client_id], provider_id: args[:provider_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/provider_type.rb b/app/graphql/types/provider_type.rb index ad6622168..9a1808cf6 100644 --- a/app/graphql/types/provider_type.rb +++ b/app/graphql/types/provider_type.rb @@ -21,40 +21,68 @@ class ProviderType < BaseObject field :download_count, Integer, null: true, description: "The number of downloads according to the Counter Code of Practice." field :citation_count, Integer, null: true, description: "The number of citations." - field :datasets, DatasetConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Authored datasets" do + field :datasets, DatasetConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Datasets by this provider." do argument :query, String, required: false - argument :client_id, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :client_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, 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 - field :publications, PublicationConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Authored publications" do + field :publications, PublicationConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Publications by this provider." do argument :query, String, required: false - argument :client_id, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :client_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, 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 - field :softwares, SoftwareConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Authored software" do + field :softwares, SoftwareConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Software by this provider." do argument :query, String, required: false - argument :client_id, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :client_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, 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 - field :works, WorkConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Authored works" do + field :works, WorkConnectionWithMetaType, null: true, connection: true, max_page_size: 1000, description: "Works by this provider." do argument :query, String, required: false - argument :client_id, String, required: false + argument :ids, String, required: false argument :user_id, String, required: false + argument :client_id, String, required: false + argument :funder_id, String, required: false + argument :affiliation_id, String, required: false + argument :resource_type_id, String, required: false + argument :has_person, Boolean, required: false + argument :has_organization, Boolean, required: false + argument :has_funder, Boolean, required: false argument :has_citations, Int, required: false argument :has_views, Int, required: false argument :has_downloads, Int, required: false @@ -87,20 +115,31 @@ def country }.compact end - def publications(query: nil, client_id: nil, user_id: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil) - Doi.query(query, user_id: user_id.present? ? orcid_from_url(user_id) : nil, client_id: client_id, provider_id: object.uid, 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 + def publications(**args) + args[:resource_type_id] = "Text" + r = response(**args) + + r.results.to_a end - def datasets(query: nil, client_id: nil, user_id: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil) - Doi.query(query, user_id: user_id.present? ? orcid_from_url(user_id) : nil, client_id: client_id, provider_id: object.uid, resource_type_id: "Dataset", state: "findable", has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, page: { number: 1, size: first }).results.to_a + def datasets(**args) + args[:resource_type_id] = "Dataset" + r = response(**args) + + r.results.to_a end - def softwares(query: nil, client_id: nil, user_id: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil) - Doi.query(query, user_id: user_id.present? ? orcid_from_url(user_id) : nil, client_id: client_id, provider_id: object.uid, 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 + def softwares(**args) + args[:resource_type_id] = "Software" + r = response(**args) + + r.results.to_a end - def works(query: nil, client_id: nil, user_id: nil, has_citations: nil, has_views: nil, has_downloads: nil, first: nil) - Doi.query(query, user_id: user_id.present? ? orcid_from_url(user_id) : nil, client_id: client_id, provider_id: object.uid, state: "findable", has_citations: has_citations, has_views: has_views, has_downloads: has_downloads, page: { number: 1, size: first }).results.to_a + def works(**args) + r = response(**args) + + r.results.to_a end def prefixes(**args) @@ -112,18 +151,24 @@ def clients(**args) end def view_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.views.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : [] end def download_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.downloads.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : [] end def citation_count - response.results.total.positive? ? aggregate_count(response.response.aggregations.citations.buckets) : [] + args = { first: 0 } + r = response(args) + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : 0 end - def response - @response ||= Doi.query(nil, provider_id: object.uid, state: "findable", page: { number: 1, size: 0 }) + def response(**args) + Doi.query(args[:query], user_id: args[:user_id], client_id: args[:client_id], provider_id: object.uid, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end