From b972749390238947f1712dbfe4be06daa00fb6b6 Mon Sep 17 00:00:00 2001 From: Rob Kaufman Date: Sun, 5 May 2024 22:36:34 -0700 Subject: [PATCH] fix rubocop errors and fix per tenant redis caching --- app/models/account.rb | 2 +- .../iiif_manifest_presenter_decorator.rb | 66 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 449795ac..fd1b74bb 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -115,7 +115,7 @@ def setup_tenant_cache(is_enabled) ActionController::Base.perform_caching = is_enabled # rubocop:disable Style/ConditionalAssignment if is_enabled - Rails.application.config.cache_store = :redis_cache_store, { url: Redis.current.id } + Rails.application.config.cache_store = :redis_cache_store, { redis: Hyrax::RedisEventStore.instance } else Rails.application.config.cache_store = :file_store, ENV.fetch('HYKU_CACHE_ROOT', '/app/samvera/file_cache') end diff --git a/app/presenters/hyrax/iiif_manifest_presenter_decorator.rb b/app/presenters/hyrax/iiif_manifest_presenter_decorator.rb index 4fbeb1f5..865d309e 100644 --- a/app/presenters/hyrax/iiif_manifest_presenter_decorator.rb +++ b/app/presenters/hyrax/iiif_manifest_presenter_decorator.rb @@ -88,49 +88,49 @@ def supplementing_content private - TRANSCRIPT_RDF_TYPE = "http://pcdm.org/use#Transcript" + TRANSCRIPT_RDF_TYPE = "http://pcdm.org/use#Transcript" - def media_and_transcript? - (audio? || video?) && transcript_attachments.present? - end + def media_and_transcript? + (audio? || video?) && transcript_attachments.present? + end - def transcript_attachments - parent = ::FileSet.find(id).parent.member_of.first - return [] unless parent + def transcript_attachments + parent = ::FileSet.find(id).parent.member_of.first + return [] unless parent - parent.members.select { |member| member.rdf_type == [TRANSCRIPT_RDF_TYPE] } - end + parent.members.select { |member| member.rdf_type == [TRANSCRIPT_RDF_TYPE] } + end - def create_supplementing_content(attachment) - hash = get_file_set_ids_and_languages(attachment) - captions_url = get_captions_url(hash[:file_set_id]) - IIIFManifest::V3::SupplementingContent.new(captions_url, - type: 'Text', - format: 'text/vtt', - label: hash[:title], - language: hash[:language].first || 'en') - end + def create_supplementing_content(attachment) + hash = get_file_set_ids_and_languages(attachment) + captions_url = get_captions_url(hash[:file_set_id]) + IIIFManifest::V3::SupplementingContent.new(captions_url, + type: 'Text', + format: 'text/vtt', + label: hash[:title], + language: hash[:language].first || 'en') + end - def get_file_set_ids_and_languages(attachment) - { - file_set_id: attachment.file_sets.first.id, - title: attachment.title.first, - language: attachment.file_language - } - end + def get_file_set_ids_and_languages(attachment) + { + file_set_id: attachment.file_sets.first.id, + title: attachment.title.first, + language: attachment.file_language + } + end - def get_captions_url(file_set_id) - captions_url = Hyrax::Engine.routes.url_helpers.download_url(file_set_id, host: hostname) - ssl_configured = Site.account.ssl_configured - ssl_configured ? captions_url.sub!(/\Ahttp:/, 'https:') : captions_url - end + def get_captions_url(file_set_id) + captions_url = Hyrax::Engine.routes.url_helpers.download_url(file_set_id, host: hostname) + ssl_configured = Site.account.ssl_configured + ssl_configured ? captions_url.sub!(/\Ahttp:/, 'https:') : captions_url + end end private - def scrub(value) - CGI.unescapeHTML(Loofah.fragment(value).scrub!(:whitewash).to_s) - end + def scrub(value) + CGI.unescapeHTML(Loofah.fragment(value).scrub!(:whitewash).to_s) + end end end