diff --git a/app/graphql/types/work_connection_with_total_type.rb b/app/graphql/types/work_connection_with_total_type.rb index 1241c465f..c8902a8de 100644 --- a/app/graphql/types/work_connection_with_total_type.rb +++ b/app/graphql/types/work_connection_with_total_type.rb @@ -7,9 +7,11 @@ class WorkConnectionWithTotalType < BaseConnection field :total_count, Integer, null: false, cache: true field :totalCountFromCrossref, resolver: TotalCountFromCrossref, null: true, cache: true + field :total_open_licenses, Integer, null: true, cache: true field :total_content_url, Integer, null: true, cache: true field :published, [FacetType], null: true, cache: true field :resource_types, [FacetType], null: true, cache: true + field :open_license_resource_types, [FacetType], null: true, cache: true field :registration_agencies, [FacetType], null: true, cache: true field :repositories, [FacetType], null: true, cache: true field :affiliations, [FacetType], null: true, cache: true @@ -26,6 +28,10 @@ def total_content_url object.aggregations.content_url_count.value.to_i end + def total_open_licenses + object.aggregations.open_licenses.doc_count.to_i + end + def published if object.aggregations.published facet_by_range(object.aggregations.published.buckets) @@ -35,13 +41,21 @@ def published end def resource_types - if object.aggregations.resource_types + if object.aggregations.authors facet_by_combined_key(object.aggregations.resource_types.buckets) else [] end end + def open_license_resource_types + if object.aggregations.open_licenses + facet_by_combined_key(object.aggregations.open_licenses.resource_types.buckets) + else + [] + end + end + def registration_agencies if object.aggregations.registration_agencies facet_by_registration_agency( diff --git a/app/models/doi.rb b/app/models/doi.rb index 4613509d7..023dd6eb0 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -588,6 +588,14 @@ def self.gql_query_aggregations(facet_count: 10) if facet_count.positive? { resource_types: { terms: { field: "resource_type_id_and_name", size: facet_count, min_doc_count: 1 } }, + open_licenses: { + filter: { terms: { "rights_list.rightsIdentifier": ["cc-by-1.0", "cc-by-2.0", "cc-by-2.5", "cc-by-3.0", "cc-by-3.0-at", "cc-by-3.0-us", "cc-by-4.0", "cc-pddc", "cc0-1.0", "cc-pdm-1.0"] } }, + aggs: { + resource_types: { + terms: { field: "resource_type_id_and_name", size: facet_count, min_doc_count: 1 } + } + } + }, published: { date_histogram: { field: "publication_year",