From 543176d8eaecc573e3dfbb81c8b3ac7717c44441 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 5 Jul 2020 15:21:03 +0200 Subject: [PATCH] simplify graphql facet code --- .../audiovisual_connection_with_total_type.rb | 12 ++++----- ...book_chapter_connection_with_total_type.rb | 12 ++++----- .../types/book_connection_with_total_type.rb | 12 ++++----- .../collection_connection_with_total_type.rb | 12 ++++----- ...erence_paper_connection_with_total_type.rb | 14 +++++----- .../data_paper_connection_with_total_type.rb | 12 ++++----- .../dataset_connection_with_total_type.rb | 26 +++++++++---------- ...dissertation_connection_with_total_type.rb | 14 +++++----- .../types/event_connection_with_total_type.rb | 12 ++++----- .../types/image_connection_with_total_type.rb | 12 ++++----- .../instrument_connection_with_total_type.rb | 10 +++---- ...ive_resource_connection_with_total_type.rb | 12 ++++----- ...rnal_article_connection_with_total_type.rb | 14 +++++----- .../member_connection_with_total_type.rb | 12 ++++----- ...ember_prefix_connection_with_total_type.rb | 4 +-- .../types/model_connection_with_total_type.rb | 12 ++++----- .../types/other_connection_with_total_type.rb | 12 ++++----- .../peer_review_connection_with_total_type.rb | 12 ++++----- ...sical_object_connection_with_total_type.rb | 12 ++++----- .../prefix_connection_with_total_type.rb | 4 +-- .../preprint_connection_with_total_type.rb | 14 +++++----- .../publication_connection_with_total_type.rb | 20 +++++++------- .../repository_connection_with_total_type.rb | 12 ++++----- ...itory_prefix_connection_with_total_type.rb | 2 +- .../service_connection_with_total_type.rb | 16 ++++++------ .../software_connection_with_total_type.rb | 20 +++++++------- .../types/sound_connection_with_total_type.rb | 12 ++++----- .../types/work_connection_with_total_type.rb | 16 ++++++------ .../workflow_connection_with_total_type.rb | 12 ++++----- 29 files changed, 183 insertions(+), 183 deletions(-) diff --git a/app/graphql/types/audiovisual_connection_with_total_type.rb b/app/graphql/types/audiovisual_connection_with_total_type.rb index 87c391014..6bc6de746 100644 --- a/app/graphql/types/audiovisual_connection_with_total_type.rb +++ b/app/graphql/types/audiovisual_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/book_chapter_connection_with_total_type.rb b/app/graphql/types/book_chapter_connection_with_total_type.rb index b7400dad0..f07aace7d 100644 --- a/app/graphql/types/book_chapter_connection_with_total_type.rb +++ b/app/graphql/types/book_chapter_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/book_connection_with_total_type.rb b/app/graphql/types/book_connection_with_total_type.rb index 637b66599..aac21e9ab 100644 --- a/app/graphql/types/book_connection_with_total_type.rb +++ b/app/graphql/types/book_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/collection_connection_with_total_type.rb b/app/graphql/types/collection_connection_with_total_type.rb index 2c53a6701..afba2accc 100644 --- a/app/graphql/types/collection_connection_with_total_type.rb +++ b/app/graphql/types/collection_connection_with_total_type.rb @@ -16,26 +16,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/conference_paper_connection_with_total_type.rb b/app/graphql/types/conference_paper_connection_with_total_type.rb index e89be9af5..c9877b77d 100644 --- a/app/graphql/types/conference_paper_connection_with_total_type.rb +++ b/app/graphql/types/conference_paper_connection_with_total_type.rb @@ -18,30 +18,30 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/data_paper_connection_with_total_type.rb b/app/graphql/types/data_paper_connection_with_total_type.rb index 73fb541bc..4e3911d41 100644 --- a/app/graphql/types/data_paper_connection_with_total_type.rb +++ b/app/graphql/types/data_paper_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/dataset_connection_with_total_type.rb b/app/graphql/types/dataset_connection_with_total_type.rb index 7fce20445..089474403 100644 --- a/app/graphql/types/dataset_connection_with_total_type.rb +++ b/app/graphql/types/dataset_connection_with_total_type.rb @@ -25,23 +25,31 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) + end + + def fields_of_science + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + end + + def languages + facet_by_language(object.aggregations.languages.buckets) end def dataset_connection_count @@ -67,12 +75,4 @@ def funder_connection_count def organization_connection_count @organization_connection_count ||= Event.query(nil, citation_type: "Dataset-Organization", page: { number: 1, size: 0 }).results.total end - - def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] - end - - def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] - end end diff --git a/app/graphql/types/dissertation_connection_with_total_type.rb b/app/graphql/types/dissertation_connection_with_total_type.rb index 2f0118a74..9f6159395 100644 --- a/app/graphql/types/dissertation_connection_with_total_type.rb +++ b/app/graphql/types/dissertation_connection_with_total_type.rb @@ -18,30 +18,30 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/event_connection_with_total_type.rb b/app/graphql/types/event_connection_with_total_type.rb index 9649a71d8..eb342190d 100644 --- a/app/graphql/types/event_connection_with_total_type.rb +++ b/app/graphql/types/event_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_year(object.aggregations.published.buckets) : [] + facet_by_year(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/image_connection_with_total_type.rb b/app/graphql/types/image_connection_with_total_type.rb index 8c8edc3e4..1e6b4d7bf 100644 --- a/app/graphql/types/image_connection_with_total_type.rb +++ b/app/graphql/types/image_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_year(object.aggregations.published.buckets) : [] + facet_by_year(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/instrument_connection_with_total_type.rb b/app/graphql/types/instrument_connection_with_total_type.rb index 85ce625e0..2461393c4 100644 --- a/app/graphql/types/instrument_connection_with_total_type.rb +++ b/app/graphql/types/instrument_connection_with_total_type.rb @@ -16,22 +16,22 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end end diff --git a/app/graphql/types/interactive_resource_connection_with_total_type.rb b/app/graphql/types/interactive_resource_connection_with_total_type.rb index 6ef18aa19..e69416f6d 100644 --- a/app/graphql/types/interactive_resource_connection_with_total_type.rb +++ b/app/graphql/types/interactive_resource_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/journal_article_connection_with_total_type.rb b/app/graphql/types/journal_article_connection_with_total_type.rb index 8390261dd..99b14a323 100644 --- a/app/graphql/types/journal_article_connection_with_total_type.rb +++ b/app/graphql/types/journal_article_connection_with_total_type.rb @@ -18,30 +18,30 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end end diff --git a/app/graphql/types/member_connection_with_total_type.rb b/app/graphql/types/member_connection_with_total_type.rb index 17fb60909..23d09f858 100644 --- a/app/graphql/types/member_connection_with_total_type.rb +++ b/app/graphql/types/member_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def years - object.total_count.positive? ? facet_by_year(object.aggregations.years.buckets) : nil + facet_by_year(object.aggregations.years.buckets) end def regions - object.total_count.positive? ? facet_by_region(object.aggregations.regions.buckets) : nil + facet_by_region(object.aggregations.regions.buckets) end def member_types - object.total_count.positive? ? facet_by_key(object.aggregations.member_types.buckets) : nil + facet_by_key(object.aggregations.member_types.buckets) end def organization_types - object.total_count.positive? ? facet_by_key(object.aggregations.organization_types.buckets) : nil + facet_by_key(object.aggregations.organization_types.buckets) end def focus_areas - object.total_count.positive? ? facet_by_key(object.aggregations.focus_areas.buckets) : nil + facet_by_key(object.aggregations.focus_areas.buckets) end def non_profit_statuses - object.total_count.positive? ? facet_by_key(object.aggregations.non_profit_statuses.buckets) : nil + facet_by_key(object.aggregations.non_profit_statuses.buckets) end end diff --git a/app/graphql/types/member_prefix_connection_with_total_type.rb b/app/graphql/types/member_prefix_connection_with_total_type.rb index a5e47a0cb..90644a3d0 100644 --- a/app/graphql/types/member_prefix_connection_with_total_type.rb +++ b/app/graphql/types/member_prefix_connection_with_total_type.rb @@ -13,10 +13,10 @@ def total_count end def states - object.total_count.positive? ? facet_by_key(object.aggregations.states.buckets) : [] + facet_by_key(object.aggregations.states.buckets) end def years - object.total_count.positive? ? facet_by_year(object.aggregations.years.buckets) : [] + facet_by_year(object.aggregations.years.buckets) end end diff --git a/app/graphql/types/model_connection_with_total_type.rb b/app/graphql/types/model_connection_with_total_type.rb index 2075654d7..8aa77292d 100644 --- a/app/graphql/types/model_connection_with_total_type.rb +++ b/app/graphql/types/model_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/other_connection_with_total_type.rb b/app/graphql/types/other_connection_with_total_type.rb index a4011a439..d1d6d9fed 100644 --- a/app/graphql/types/other_connection_with_total_type.rb +++ b/app/graphql/types/other_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def years - object.total_count.positive? ? facet_by_range(object.aggregations.years.buckets) : [] + facet_by_range(object.aggregations.years.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object_id.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object_id.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/peer_review_connection_with_total_type.rb b/app/graphql/types/peer_review_connection_with_total_type.rb index d0e9e44c5..6b1bfc932 100644 --- a/app/graphql/types/peer_review_connection_with_total_type.rb +++ b/app/graphql/types/peer_review_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_software(object.aggregations.registration_agencies.buckets) : [] + facet_by_software(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/physical_object_connection_with_total_type.rb b/app/graphql/types/physical_object_connection_with_total_type.rb index 908ee459e..7d2db2b69 100644 --- a/app/graphql/types/physical_object_connection_with_total_type.rb +++ b/app/graphql/types/physical_object_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def years - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object_id.aggregations.clients.buckets) : [] + facet_by_combined_key(object_id.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/prefix_connection_with_total_type.rb b/app/graphql/types/prefix_connection_with_total_type.rb index 61fac5329..57e136870 100644 --- a/app/graphql/types/prefix_connection_with_total_type.rb +++ b/app/graphql/types/prefix_connection_with_total_type.rb @@ -13,10 +13,10 @@ def total_count end def states - object.total_count.positive? ? facet_by_key(object.aggregations.states.buckets) : [] + facet_by_key(object.aggregations.states.buckets) end def years - object.total_count.positive? ? facet_by_year(object.aggregations.years.buckets) : [] + facet_by_year(object.aggregations.years.buckets) end end diff --git a/app/graphql/types/preprint_connection_with_total_type.rb b/app/graphql/types/preprint_connection_with_total_type.rb index 448a3328c..d13be3aaa 100644 --- a/app/graphql/types/preprint_connection_with_total_type.rb +++ b/app/graphql/types/preprint_connection_with_total_type.rb @@ -18,30 +18,30 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/publication_connection_with_total_type.rb b/app/graphql/types/publication_connection_with_total_type.rb index 53d6378b9..04a285747 100644 --- a/app/graphql/types/publication_connection_with_total_type.rb +++ b/app/graphql/types/publication_connection_with_total_type.rb @@ -25,27 +25,31 @@ def total_count end def published - object.total_count.positive? ? facet_by_year(object.aggregations.published.buckets) : [] + facet_by_year(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_software(object.aggregations.registration_agencies.buckets) : [] + facet_by_software(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) + end + + def fields_of_science + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def publication_connection_count @@ -71,8 +75,4 @@ def funder_connection_count def organization_connection_count @organization_connection_count ||= Event.query(nil, citation_type: "Organization-ScholarlyArticle", page: { number: 1, size: 0 }).results.total end - - def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] - end end diff --git a/app/graphql/types/repository_connection_with_total_type.rb b/app/graphql/types/repository_connection_with_total_type.rb index 28bb186ff..5020aad82 100644 --- a/app/graphql/types/repository_connection_with_total_type.rb +++ b/app/graphql/types/repository_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def years - object.total_count.positive? ? facet_by_year(object.aggregations.years.buckets) : nil + facet_by_year(object.aggregations.years.buckets) end def members - object.total_count.positive? ? facet_by_combined_key(object.aggregations.providers.buckets) : nil + facet_by_combined_key(object.aggregations.providers.buckets) end def software - object.total_count.positive? ? facet_by_software(object.aggregations.software.buckets) : nil + facet_by_software(object.aggregations.software.buckets) end def certificates - object.total_count.positive? ? facet_by_key(object.aggregations.certificates.buckets) : nil + facet_by_key(object.aggregations.certificates.buckets) end def client_types - object.total_count.positive? ? facet_by_key(object.aggregations.client_types.buckets) : nil + facet_by_key(object.aggregations.client_types.buckets) end def repository_types - object.total_count.positive? ? facet_by_key(object.aggregations.repository_types.buckets) : nil + facet_by_key(object.aggregations.repository_types.buckets) end end diff --git a/app/graphql/types/repository_prefix_connection_with_total_type.rb b/app/graphql/types/repository_prefix_connection_with_total_type.rb index d499edf58..c22f97d0d 100644 --- a/app/graphql/types/repository_prefix_connection_with_total_type.rb +++ b/app/graphql/types/repository_prefix_connection_with_total_type.rb @@ -12,6 +12,6 @@ def total_count end def years - object.total_count.positive? ? facet_by_year(object.aggregations.years.buckets) : [] + facet_by_year(object.aggregations.years.buckets) end end diff --git a/app/graphql/types/service_connection_with_total_type.rb b/app/graphql/types/service_connection_with_total_type.rb index 1319614d8..74939ee72 100644 --- a/app/graphql/types/service_connection_with_total_type.rb +++ b/app/graphql/types/service_connection_with_total_type.rb @@ -19,34 +19,34 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def pid_entities - object.total_count.positive? ? facet_by_software(object.aggregations.pid_entities.subject.buckets) : [] + facet_by_software(object.aggregations.pid_entities.subject.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/software_connection_with_total_type.rb b/app/graphql/types/software_connection_with_total_type.rb index 71751a93e..b7e3bc6c7 100644 --- a/app/graphql/types/software_connection_with_total_type.rb +++ b/app/graphql/types/software_connection_with_total_type.rb @@ -25,27 +25,31 @@ def total_count end def published - object.total_count.positive? ? facet_by_year(object.aggregations.published.buckets) : [] + facet_by_year(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) + end + + def fields_of_science + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def software_connection_count @@ -71,8 +75,4 @@ def funder_connection_count def organization_connection_count Event.query(nil, citation_type: "Organization-SoftwareSourceCode", page: { number: 1, size: 0 }).results.total end - - def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] - end end diff --git a/app/graphql/types/sound_connection_with_total_type.rb b/app/graphql/types/sound_connection_with_total_type.rb index de0a0b04a..79e07c88e 100644 --- a/app/graphql/types/sound_connection_with_total_type.rb +++ b/app/graphql/types/sound_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/work_connection_with_total_type.rb b/app/graphql/types/work_connection_with_total_type.rb index fdd9d8a89..9582c14af 100644 --- a/app/graphql/types/work_connection_with_total_type.rb +++ b/app/graphql/types/work_connection_with_total_type.rb @@ -19,34 +19,34 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def resource_types - object.total_count.positive? ? facet_by_combined_key(object.aggregations.resource_types.buckets) : [] + facet_by_combined_key(object.aggregations.resource_types.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def fields_of_science - object.total_count.positive? ? facet_by_fos(object.aggregations.fields_of_science.subject.buckets) : [] + facet_by_fos(object.aggregations.fields_of_science.subject.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end diff --git a/app/graphql/types/workflow_connection_with_total_type.rb b/app/graphql/types/workflow_connection_with_total_type.rb index c637ae250..2f1d7a562 100644 --- a/app/graphql/types/workflow_connection_with_total_type.rb +++ b/app/graphql/types/workflow_connection_with_total_type.rb @@ -17,26 +17,26 @@ def total_count end def published - object.total_count.positive? ? facet_by_range(object.aggregations.published.buckets) : [] + facet_by_range(object.aggregations.published.buckets) end def registration_agencies - object.total_count.positive? ? facet_by_registration_agency(object.aggregations.registration_agencies.buckets) : [] + facet_by_registration_agency(object.aggregations.registration_agencies.buckets) end def repositories - object.total_count.positive? ? facet_by_combined_key(object.aggregations.clients.buckets) : [] + facet_by_combined_key(object.aggregations.clients.buckets) end def affiliations - object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : [] + facet_by_combined_key(object.aggregations.affiliations.buckets) end def licenses - object.total_count.positive? ? facet_by_license(object.aggregations.licenses.buckets) : [] + facet_by_license(object.aggregations.licenses.buckets) end def languages - object.total_count.positive? ? facet_by_language(object.aggregations.languages.buckets) : [] + facet_by_language(object.aggregations.languages.buckets) end end