Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo into schema…
Browse files Browse the repository at this point in the history
…-3-dep
  • Loading branch information
codycooperross committed Dec 30, 2024
2 parents 67a040a + 6a00203 commit d21b8cd
Show file tree
Hide file tree
Showing 22 changed files with 1,221 additions and 181 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ doc/dependencies*
!.env.travis
!.env.build
docker-compose.override.yml
.ruby-version
.vscode
.solargraph.yml
.devspace
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.6
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem "aws-sdk-sqs", "~> 1.3"
gem "base32-url", "~> 0.3"
gem "batch-loader", "~> 1.4", ">= 1.4.1"
gem "bcrypt", "~> 3.1.7"
gem "bolognese", "~> 2.2"
gem "bolognese", "~> 2.3.2"
gem "bootsnap", "~> 1.4", ">= 1.4.4", require: false
gem "cancancan", "~> 3.0"
gem "countries", "~> 2.1", ">= 2.1.2"
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ GEM
bigdecimal (3.1.6)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bolognese (2.2.0)
bolognese (2.3.2)
activesupport (>= 4.2.5)
benchmark_methods (~> 0.7)
bibtex-ruby (>= 5.1.0)
Expand Down Expand Up @@ -768,6 +768,7 @@ GEM

PLATFORMS
aarch64-linux
arm64-darwin-23
universal-darwin-21
x86_64-darwin-20
x86_64-linux
Expand All @@ -785,7 +786,7 @@ DEPENDENCIES
bcrypt (~> 3.1.7)
better_errors
binding_of_caller
bolognese (~> 2.2)
bolognese (~> 2.3.2)
bootsnap (~> 1.4, >= 1.4.4)
brakeman (~> 6.1, >= 6.1.2)
bullet (~> 7.1, >= 7.1.6)
Expand Down Expand Up @@ -882,4 +883,4 @@ DEPENDENCIES
webmock (~> 3.18, >= 3.18.1)

BUNDLED WITH
2.5.6
2.3.27
113 changes: 50 additions & 63 deletions app/controllers/datacite_dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def index
if params[:id].present?
response = DataciteDoi.find_by_id(params[:id])
elsif params[:ids].present?
response = DataciteDoi.find_by_ids(params[:ids], page: page, sort: sort)
response = DataciteDoi.find_by_ids(params[:ids], disable_facets: params[:disable_facets], facets: params[:facets], page: page, sort: sort)
else
response =
DataciteDoi.query(
Expand Down Expand Up @@ -136,6 +136,7 @@ def index
source: params[:source],
scroll_id: params[:scroll_id],
disable_facets: disable_facets,
facets: params[:facets],
page: page,
sort: sort,
random: params[:random],
Expand Down Expand Up @@ -203,6 +204,7 @@ def index
detail: params[:detail],
affiliation: params[:affiliation],
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
is_collection: options[:is_collection],
}

Expand All @@ -220,46 +222,44 @@ def index
)
end
else
if total.positive? && !disable_facets
states = facet_by_key(response.aggregations.states.buckets)
resource_types = facet_by_combined_key(response.aggregations.resource_types.buckets)
published = facet_by_range(response.aggregations.published.buckets)
created = facet_by_key_as_string(response.aggregations.created.buckets)
created_by_month = response.aggregations.created_by_month ? facet_by_key_as_string(response.aggregations.created_by_month.buckets) : nil
registered = facet_by_key_as_string(response.aggregations.registered.buckets)
providers = facet_by_combined_key(response.aggregations.providers.buckets)
clients = facet_by_combined_key(response.aggregations.clients.buckets)
prefixes = facet_by_key(response.aggregations.prefixes.buckets)
schema_versions = facet_by_schema(response.aggregations.schema_versions.buckets)
affiliations = facet_by_combined_key(response.aggregations.affiliations.buckets)
subjects = facet_by_key(response.aggregations.subjects.buckets)
fields_of_science = facet_by_fos(response.aggregations.fields_of_science.subject.buckets)
certificates = facet_by_key(response.aggregations.certificates.buckets)
licenses = facet_by_license(response.aggregations.licenses.buckets)
link_checks_status = facet_by_cumulative_year(response.aggregations.link_checks_status.buckets)
citations = metric_facet_by_year(response.aggregations.citations.buckets)
views = metric_facet_by_year(response.aggregations.views.buckets)
downloads = metric_facet_by_year(response.aggregations.downloads.buckets)
else
states = nil
resource_types = nil
published = nil
created = nil
registered = nil
providers = nil
clients = nil
prefixes = nil
schema_versions = nil
affiliations = nil
subjects = nil
fields_of_science = nil
certificates = nil
licenses = nil
link_checks_status = nil
citations = nil
views = nil
downloads = nil
end
facets_to_facet_methods = {
states: :facet_by_key,
resource_types: :facet_by_combined_key,
created: :facet_by_key_as_string,
created_by_month: :facet_by_key_as_string,
published: :facet_by_range,
registered: :facet_by_key_as_string,
providers: :facet_by_combined_key,
clients: :facet_by_combined_key,
client_types: :facet_by_client_type,
affiliations: :facet_by_combined_key,
prefixes: :facet_by_key,
certificates: :facet_by_key,
licenses: :facet_by_license,
schema_versions: :facet_by_schema,
link_checks_status: :facet_by_cumulative_year,
creators_and_contributors: :facet_by_creators_and_contributors,
subjects: :facet_by_key,
fields_of_science: :facet_by_fos,
languages: :facet_by_language,
registration_agencies: :facet_by_registration_agency,
citations: :metric_facet_by_year,
views: :metric_facet_by_year,
downloads: :metric_facet_by_year
}

facets_to_bucket_path = {
fields_of_science: [:subject, :buckets]
}

aggregations = response.aggregations
facets = total == 0 ? {} :
facets_to_facet_methods.map do |facet, method|
if aggregations.dig(facet)
buckets = facets_to_bucket_path.dig(facet) ? aggregations.dig(facet, *facets_to_bucket_path[facet]) : aggregations.dig(facet).buckets
[facet.to_s.camelize(:lower), send(method, buckets)]
end
end.compact.to_h

respond_to do |format|
format.json do
Expand All @@ -270,27 +270,8 @@ def index
page:
if page[:cursor].nil? && page[:number].present?
page[:number]
end,
states: states,
"resourceTypes" => resource_types,
created: created,
createdByMonth: created_by_month,
published: published,
registered: registered,
providers: providers,
clients: clients,
affiliations: affiliations,
prefixes: prefixes,
certificates: certificates,
licenses: licenses,
"schemaVersions" => schema_versions,
"linkChecksStatus" => link_checks_status,
subjects: subjects,
"fieldsOfScience" => fields_of_science,
citations: citations,
views: views,
downloads: downloads,
}.compact
end
}.merge(facets).compact

options[:links] = {
self: request.original_url,
Expand Down Expand Up @@ -324,6 +305,7 @@ def index
"has-affiliation" => params[:has_affiliation],
"has-funder" => params[:has_funder],
"disable-facets" => params[:disable_facets],
"facets" => params[:facets],
detail: params[:detail],
composite: params[:composite],
affiliation: params[:affiliation],
Expand All @@ -349,6 +331,7 @@ def index
composite: params[:composite],
affiliation: params[:affiliation],
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
is_collection: options[:is_collection],
}

Expand Down Expand Up @@ -447,6 +430,7 @@ def show
composite: nil,
affiliation: params[:affiliation],
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
}

render(
Expand Down Expand Up @@ -504,7 +488,8 @@ def validate
options[:params] = {
current_ability: current_ability,
affiliation: params[:affiliation],
publisher: params[:publisher]
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
}

render(
Expand Down Expand Up @@ -535,6 +520,7 @@ def create
detail: true,
affiliation: params[:affiliation],
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
}

render(
Expand Down Expand Up @@ -595,6 +581,7 @@ def update
detail: true,
affiliation: params[:affiliation],
publisher: params[:publisher],
include_other_registration_agencies: params[:include_other_registration_agencies],
}

render(
Expand Down
Loading

0 comments on commit d21b8cd

Please sign in to comment.