Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 14, 2021
2 parents a6a3615 + beb100e commit d122d9f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/graphql/types/work_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d122d9f

Please sign in to comment.