From 66b90343bdc34b37f4caa55ccc614b5dc4e06ff0 Mon Sep 17 00:00:00 2001 From: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:11:04 -0800 Subject: [PATCH 1/2] load decorator files --- config/application.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/application.rb b/config/application.rb index 3d56543..f3a12ef 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,5 +19,12 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + + config.to_prepare do + # Allows us to use decorator files + Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator*.rb')).sort.each do |c| + Rails.configuration.cache_classes ? require(c) : load(c) + end + end end end From c9243bcfa1c0858c37393f2eaf6995f7467e2087 Mon Sep 17 00:00:00 2001 From: Benjamin Kiah Stroud <32469930+bkiahstroud@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:11:51 -0800 Subject: [PATCH 2/2] fix 414 URI too long error on "Review Submissions" Backport a bug fix from Hyrax v4.0.0 that prevents a "Request URI too long" RSolr error from being thrown on the "Review Submissions" page when there are many works pending review --- .../hyrax/solr_query_service_decorator.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/services/hyrax/solr_query_service_decorator.rb diff --git a/app/services/hyrax/solr_query_service_decorator.rb b/app/services/hyrax/solr_query_service_decorator.rb new file mode 100644 index 0000000..c94407b --- /dev/null +++ b/app/services/hyrax/solr_query_service_decorator.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# OVERRIDE FILE from Hyrax v3.1.0 - delete after upgrading to Hyrax >= v4.0.0 + +module Hyrax + # This decorator backports a conceptual fix from Hyrax v4.0.0. It + # prevents a `414 Request-URI Too Long` RSolr error from being + # thrown on the "Review Submissions" page (/admin/workflows). + # + # This is a "conceptual" fix because it is not a line-for-line change + # from Hyrax v4.0.0. Rather, it backports the concept that using + # POST instead of GET allows for larger requests to be sent to Solr. + # + # Reference: https://github.com/samvera/hyrax/issues/5926 + module SolrQueryServiceDecorator + ## + # @return [Enumerable] + def solr_documents + # OVERRIDE: replace #get with solr_service#post + solr_service.post(build)['response']['docs'].map { |doc| self.class.document_model.new(doc) } + end + end +end + +Hyrax::SolrQueryService.prepend(Hyrax::SolrQueryServiceDecorator)