From c8ad84cb1535087b5a4f921f45e33427c37e397e Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Thu, 15 Aug 2024 16:55:54 -0700 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=92=84=20Fixing=20linting=20for=20Adv?= =?UTF-8?q?entist=20Valkyrie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the linting issues on the Adventist Valkyrie project. The files in this commit have been modified by either rubocop auto fixes or manual disable and enable notations. There should not be any changes to the functionality of the application. Ref: - https://github.com/scientist-softserv/adventist_knapsack/issues/741 --- .rubocop.yml | 16 +- .../actors/collections_membership_actor.rb | 185 ++++++++-------- ...reate_with_remote_files_actor_decorator.rb | 10 +- .../hyrax/actors/file_set_actor_decorator.rb | 6 +- .../catalog_controller_decorator.rb | 1 - .../hyrax/homepage_controller_decorator.rb | 7 +- app/indexers/app_indexer_decorator.rb | 9 +- app/jobs/create_derivatives_job_decorator.rb | 2 +- app/jobs/file_sets_reprocess_job.rb | 12 +- .../child_works_from_pdf_job_decorator.rb | 30 +-- app/jobs/index_plain_text_files_job.rb | 63 +++--- app/jobs/reload_pdfs_to_split_job.rb | 4 +- app/jobs/reload_single_pdf_job.rb | 4 +- app/jobs/remove_account_relationships_job.rb | 2 +- .../bulkrax/application_matcher_decorator.rb | 2 + app/models/ability_decorator.rb | 2 + app/models/collection_decorator.rb | 48 +++-- .../concerns/bulkrax/has_local_processing.rb | 8 +- app/models/concerns/slug_bug.rb | 12 +- app/models/content_block_decorator.rb | 2 +- .../bulkrax/oai_adventist_qdc_parser.rb | 11 +- app/search_builders/adv_search_builder.rb | 5 +- .../text_file_text_extraction_service.rb | 4 +- .../daily_solr_content_check_service.rb | 4 +- .../hyrax/custom_queries/find_by_slug.rb | 12 +- .../hyrax/work_uploads_handler_decorator.rb | 3 +- ...fest_builder_service_behavior_decorator.rb | 44 ++-- .../adventist_pages_to_jpgs_splitter.rb | 2 +- lib/adl/transactions/steps/set_slug.rb | 2 +- lib/dog_biscuits/blacklight/commands.rb | 202 +++++++++--------- lib/dog_biscuits/importers/authority.rb | 52 ++--- .../indexers/concerns/indexes_common.rb | 4 +- lib/dog_biscuits/services/terms_service.rb | 80 +++---- lib/dog_biscuits/vocab/borthwick_registers.rb | 2 + lib/dog_biscuits/vocab/generic.rb | 2 + lib/dog_biscuits/vocab/oais_archivematica.rb | 2 + lib/hyku_knapsack/engine.rb | 16 +- .../metadata_format/adl_dublin_core.rb | 4 + .../metadata_format/qualified_dublin_core.rb | 2 + lib/oai/provider/model_decorator.rb | 2 + lib/tasks/maintenance.rake | 2 +- .../jobs/add_works_to_collections_job.rb | 2 +- .../jobs/collection_membership_job.rb | 2 + .../rerun_errored_entries_for_importer_job.rb | 2 + spec/bulkrax/entry_spec_helper.rb | 22 +- spec/features/create_conference_item_spec.rb | 3 +- spec/features/create_dataset_spec.rb | 3 +- spec/features/create_exam_paper_spec.rb | 3 +- spec/features/create_journal_article_spec.rb | 3 +- spec/features/create_published_work_spec.rb | 3 +- spec/features/create_thesis_spec.rb | 3 +- spec/features/facet_by_year_spec.rb | 2 +- .../hyku_knapsack/application_helper_spec.rb | 4 +- .../adventist_pages_to_jpgs_splitter_spec.rb | 2 +- .../create_derivatives_job_decorator_spec.rb | 4 +- spec/jobs/file_sets_reprocess_job_spec.rb | 4 +- spec/models/bulkrax/csv_entry_spec.rb | 4 +- .../bulkrax/oai_adventist_qdc_entry_spec.rb | 4 +- .../bulkrax/oai_adventist_set_entry_spec.rb | 4 +- spec/rails_helper.rb | 2 +- 60 files changed, 503 insertions(+), 455 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0cdaa5de..73741d6c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,11 +9,22 @@ AllCops: # NOTE: When we run knapsack's rubocop, we don't want to check the submodule # for Hyku. We'll assume it's okay and has it's own policing policies. - "hyrax-webapp/**/*" + - 'bin/**/*' + - 'db/**/*' + - 'config/**/*' + - 'vendor/**/*' + - 'lib/tasks/rubocop.rake' Metrics/BlockLength: IgnoredMethods: ['included', 'describe', 'it', 'context'] Exclude: - "spec/**/*.rb" + - app/controllers/catalog_controller_decorator.rb + +Metrics/ModuleLength: + Exclude: + - lib/dog_biscuits.rb + - app/models/solr_document_decorator.rb Style/AsciiComments: Enabled: false @@ -75,4 +86,7 @@ RSpec/NestedGroups: Enabled: false RSpec/LeadingSubject: - Enabled: false \ No newline at end of file + Enabled: false + +RSpec/ExampleLength: + Max: 16 diff --git a/app/actors/hyrax/actors/collections_membership_actor.rb b/app/actors/hyrax/actors/collections_membership_actor.rb index feffcaf5..705b340c 100644 --- a/app/actors/hyrax/actors/collections_membership_actor.rb +++ b/app/actors/hyrax/actors/collections_membership_actor.rb @@ -30,106 +30,103 @@ def update(env) private - ## - # Attaches any unattached members. Deletes those that are marked _delete - # - # @param env [Hyrax::Actors::Enviornment] - # @return [Boolean] - # - # rubocop:disable Metrics/PerceivedComplexity - # rubocop:disable Metrics/CyclomaticComplexity - def assign_nested_attributes_for_collection(env) - attributes_collection = env.attributes.delete(:member_of_collections_attributes) - return true unless attributes_collection - - # OVERRIDE Hyrax 3.5.0 to skip permission checks if importing - # rubocop:disable Metrics/LineLength - return false unless env.importing || - valid_membership?(env, - collection_ids: attributes_collection.map { |_, attributes| attributes['id'] }) - - # rubocop:enable Metrics/LineLength - attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } - # checking for existing works to avoid rewriting/loading works that are already attached - existing_collections = env.curation_concern.member_of_collection_ids - boolean_type_caster = ActiveModel::Type::Boolean.new - attributes_collection.each do |attributes| - next if attributes['id'].blank? - if boolean_type_caster.cast(attributes['_destroy']) - # Likely someone in the UI sought to add the collection, then - # changed their mind and checked the "delete" checkbox and posted - # their update. - next unless existing_collections.include?(attributes['id']) - remove(env.curation_concern, attributes['id']) - else - # Let's not try to add an item already - next if existing_collections.include?(attributes['id']) - add(env, attributes['id']) - end + ## + # Attaches any unattached members. Deletes those that are marked _delete + # + # @param env [Hyrax::Actors::Enviornment] + # @return [Boolean] + # + # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength + def assign_nested_attributes_for_collection(env) + attributes_collection = env.attributes.delete(:member_of_collections_attributes) + return true unless attributes_collection + + # OVERRIDE Hyrax 3.5.0 to skip permission checks if importing + # rubocop:disable Metrics/LineLength + return false unless env.importing || + valid_membership?(env, + collection_ids: attributes_collection.map { |_, attributes| attributes['id'] }) + + # rubocop:enable Metrics/LineLength + attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } + # checking for existing works to avoid rewriting/loading works that are already attached + existing_collections = env.curation_concern.member_of_collection_ids + boolean_type_caster = ActiveModel::Type::Boolean.new + attributes_collection.each do |attributes| + next if attributes['id'].blank? + if boolean_type_caster.cast(attributes['_destroy']) + # Likely someone in the UI sought to add the collection, then + # changed their mind and checked the "delete" checkbox and posted + # their update. + next unless existing_collections.include?(attributes['id']) + remove(env.curation_concern, attributes['id']) + else + # Let's not try to add an item already + next if existing_collections.include?(attributes['id']) + add(env, attributes['id']) end - true - end - # rubocop:enable Metrics/MethodLength - # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity - - # Adds the item to the ordered members so that it displays in the items - # along side the FileSets on the show page - def add(env, id) - collection = Hyrax.config.collection_class.find(id) - collection.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) - - return unless env.current_ability.can?(:deposit, collection) - env.curation_concern.member_of_collections << collection end + true + end + # rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity - # Remove the object from the members set and the ordered members list - def remove(curation_concern, id) - collection = Hyrax.config.collection_class.find(id) - curation_concern.member_of_collections.delete(collection) - end + # Adds the item to the ordered members so that it displays in the items + # along side the FileSets on the show page + def add(env, id) + collection = Hyrax.config.collection_class.find(id) + collection.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) - # Extact a singleton collection id from the collection attributes and save it in env. Later in the actor stack, - # in apply_permission_template_actor.rb, `env.attributes[:collection_id]` will be used to apply the - # permissions of the collection to the created work. With one and only one collection, the work is seen as - # being created directly in that collection. The permissions will not be applied to the work if the collection - # type is configured not to allow that or if the work is being created in more than one collection. - # - # @param env [Hyrax::Actors::Enviornment] - # - # Given an array of collection_attributes when it is size: - # * 0 do not set `env.attributes[:collection_id]` - # * 1 set `env.attributes[:collection_id]` to the one and only one collection - # * 2+ do not set `env.attributes[:collection_id]` - # - # NOTE: Only called from create. All collections are being added as parents of a work. None are being removed. - def extract_collection_id(env) - attributes_collection = - env.attributes.fetch(:member_of_collections_attributes) { nil } - - # Determine if the work is being created in one and only one collection. - return unless attributes_collection && attributes_collection.size == 1 - - # Extract the collection id from attributes_collection, - collection_id = attributes_collection.first.second['id'] - - # Do not apply permissions to work if collection type is configured not to - collection = Hyrax.config.collection_class.find(collection_id) - return unless collection.share_applies_to_new_works? - - # Save the collection id in env for use in apply_permission_template_actor - env.attributes[:collection_id] = collection_id - end + return unless env.current_ability.can?(:deposit, collection) + env.curation_concern.member_of_collections << collection + end - def valid_membership?(env, collection_ids:) - checker = Hyrax::MultipleMembershipChecker.new(item: env.curation_concern) - multiple_memberships = checker.check(collection_ids: collection_ids) - if multiple_memberships - env.curation_concern.errors.add(:collections, multiple_memberships) - return false - end - true + # Remove the object from the members set and the ordered members list + def remove(curation_concern, id) + collection = Hyrax.config.collection_class.find(id) + curation_concern.member_of_collections.delete(collection) + end + + # Extact a singleton collection id from the collection attributes and save it in env. Later in the actor stack, + # in apply_permission_template_actor.rb, `env.attributes[:collection_id]` will be used to apply the + # permissions of the collection to the created work. With one and only one collection, the work is seen as + # being created directly in that collection. The permissions will not be applied to the work if the collection + # type is configured not to allow that or if the work is being created in more than one collection. + # + # @param env [Hyrax::Actors::Enviornment] + # + # Given an array of collection_attributes when it is size: + # * 0 do not set `env.attributes[:collection_id]` + # * 1 set `env.attributes[:collection_id]` to the one and only one collection + # * 2+ do not set `env.attributes[:collection_id]` + # + # NOTE: Only called from create. All collections are being added as parents of a work. None are being removed. + def extract_collection_id(env) + attributes_collection = + env.attributes.fetch(:member_of_collections_attributes) { nil } + + # Determine if the work is being created in one and only one collection. + return unless attributes_collection && attributes_collection.size == 1 + + # Extract the collection id from attributes_collection, + collection_id = attributes_collection.first.second['id'] + + # Do not apply permissions to work if collection type is configured not to + collection = Hyrax.config.collection_class.find(collection_id) + return unless collection.share_applies_to_new_works? + + # Save the collection id in env for use in apply_permission_template_actor + env.attributes[:collection_id] = collection_id + end + + def valid_membership?(env, collection_ids:) + checker = Hyrax::MultipleMembershipChecker.new(item: env.curation_concern) + multiple_memberships = checker.check(collection_ids:) + if multiple_memberships + env.curation_concern.errors.add(:collections, multiple_memberships) + return false end + true + end end end end diff --git a/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb b/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb index f407a703..d61de3e5 100644 --- a/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb +++ b/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb @@ -8,6 +8,7 @@ module CreateWithRemoteFilesActorDecorator module IngestRemoteFilesServiceDecorator ## # @return true + # rubocop:disable Metrics/MethodLength def attach! return true unless remote_files remote_files.each do |file_info| @@ -27,21 +28,22 @@ def attach! add_ordered_members! if ordered true end + # rubocop:enable Metrics/LineLength def create_file_from_url(uri, file_name, auth_header, override_default_thumbnail = nil) import_url = URI.decode_www_form_component(uri.to_s) use_valkyrie = false case curation_concern when Valkyrie::Resource - file_set = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url: import_url, label: file_name)) + file_set = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url:, label: file_name)) use_valkyrie = true else # OVERRIDE Hyrax 3.5 to override default_thumbnail - file_set = ::FileSet.new(import_url: import_url, + file_set = ::FileSet.new(import_url:, label: file_name, - override_default_thumbnail: override_default_thumbnail) + override_default_thumbnail:) end - __create_file_from_url(file_set: file_set, uri: uri, auth_header: auth_header, use_valkyrie: use_valkyrie) + __create_file_from_url(file_set:, uri:, auth_header:, use_valkyrie:) end end end diff --git a/app/actors/hyrax/actors/file_set_actor_decorator.rb b/app/actors/hyrax/actors/file_set_actor_decorator.rb index 41810da0..1ac6127d 100644 --- a/app/actors/hyrax/actors/file_set_actor_decorator.rb +++ b/app/actors/hyrax/actors/file_set_actor_decorator.rb @@ -5,11 +5,12 @@ module Hyrax module Actors module FileSetActorDecorator + # rubocop:disable Metrics/AbcSize def attach_to_valkyrie_work(work, file_set_params) work = Hyrax.query_service.find_by(id: work.id) unless work.new_record file_set.visibility = work.visibility unless assign_visibility?(file_set_params) fs = Hyrax.persister.save(resource: file_set) - Hyrax.publisher.publish('object.metadata.updated', object: fs, user: user) + Hyrax.publisher.publish('object.metadata.updated', object: fs, user:) work.member_ids << fs.id work.representative_id = fs.id if work.representative_id.blank? # OVERRIDE Hyrax 3.5.0 to override default_thumbnail @@ -18,8 +19,9 @@ def attach_to_valkyrie_work(work, file_set_params) # Save the work so the association between the work and the file_set is persisted (head_id) # NOTE: the work may not be valid, in which case this save doesn't do anything. Hyrax.persister.save(resource: work) - Hyrax.publisher.publish('object.metadata.updated', object: work, user: user) + Hyrax.publisher.publish('object.metadata.updated', object: work, user:) end + # rubocop:enable Metrics/AbcSize # Adds a FileSet to the work using ore:Aggregations. def attach_to_af_work(work, file_set_params) diff --git a/app/controllers/catalog_controller_decorator.rb b/app/controllers/catalog_controller_decorator.rb index 585f81f3..f659f0b4 100644 --- a/app/controllers/catalog_controller_decorator.rb +++ b/app/controllers/catalog_controller_decorator.rb @@ -123,4 +123,3 @@ def self.uploaded_field config.add_sort_field "#{CatalogController.modified_field} asc", label: "Upload Date (Ascending)" config.add_sort_field "#{CatalogController.modified_field} desc", label: "Upload Date (Descending)" end -# rubocop:enable Metrics/BlockLength diff --git a/app/controllers/hyrax/homepage_controller_decorator.rb b/app/controllers/hyrax/homepage_controller_decorator.rb index 64519cf7..47328eaa 100644 --- a/app/controllers/hyrax/homepage_controller_decorator.rb +++ b/app/controllers/hyrax/homepage_controller_decorator.rb @@ -3,7 +3,7 @@ # OVERRIDE Hyku 5 to add homepage about blocks module Hyrax module HomepageControllerDecorator - + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def index # BEGIN copy Hyrax prime's Hyrax::HomepageController#index @presenter = presenter_class.new(current_ability, collections) @@ -15,7 +15,7 @@ def index @homepage_about_section_heading = ContentBlock.for(:homepage_about_section_heading) @homepage_about_section_content = ContentBlock.for(:homepage_about_section_content) # END OVERRIDE - + recent # END copy @@ -42,8 +42,7 @@ def index document_export_formats(format) end end - - + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength end end diff --git a/app/indexers/app_indexer_decorator.rb b/app/indexers/app_indexer_decorator.rb index 62a1fd46..65de8eba 100644 --- a/app/indexers/app_indexer_decorator.rb +++ b/app/indexers/app_indexer_decorator.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module AppIndexerDecorator + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def generate_solr_document super.tap do |solr_doc| solr_doc["account_cname_tesim"] = Site.instance&.account&.cname @@ -11,9 +12,9 @@ def generate_solr_document solr_doc['fedora_id_ssi'] = object.id solr_doc[ActiveFedora.id_field.to_sym] = object.to_param solr_doc['source_sim'] = solr_doc['source_tesim'] - solr_doc['file_set_text_tsimv'] = child_works_file_sets(object: object).map { |fs| all_text(object: fs) } - .select(&:present?) - .join("\n---------------------------\n") + solr_doc['file_set_text_tsimv'] = child_works_file_sets(object:).map { |fs| all_text(object: fs) } + .select(&:present?) + .join("\n---------------------------\n") if object.date_created.present? # rubocop:disable Metrics/LineLength @@ -26,7 +27,7 @@ def generate_solr_document end end end - # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength def child_works_file_sets(object:) object.works.map { |work| work.file_sets.to_a }.flatten diff --git a/app/jobs/create_derivatives_job_decorator.rb b/app/jobs/create_derivatives_job_decorator.rb index dcb18bde..da821293 100644 --- a/app/jobs/create_derivatives_job_decorator.rb +++ b/app/jobs/create_derivatives_job_decorator.rb @@ -4,7 +4,7 @@ module CreateDerivativesJobDecorator # @note Override to include conditional validation def perform(file_set, file_id, filepath = nil) - return unless CreateDerivativesJobDecorator.create_derivative_for?(file_set: file_set) + return unless CreateDerivativesJobDecorator.create_derivative_for?(file_set:) super end diff --git a/app/jobs/file_sets_reprocess_job.rb b/app/jobs/file_sets_reprocess_job.rb index 8347e128..63f283ab 100644 --- a/app/jobs/file_sets_reprocess_job.rb +++ b/app/jobs/file_sets_reprocess_job.rb @@ -14,7 +14,7 @@ class FileSetsReprocessJob < ApplicationJob # Otherwise, switch to the given tenant and submit a {FileSetsReprocessJob} def self.for_tenant(cname = :all) if cname == :all - Account.all.each do |account| + Account.all.find_each do |account| account.switch! FileSetsReprocessJob.perform_later end @@ -64,7 +64,7 @@ def self.find(file_set_id:) message = "#{self.class}##{__method__} unable to find FileSet with ID=#{file_set_id}. " \ "It may have been deleted between the enqueuing of this job and running this job." Rails.logger.warning(message) - return false + false end end @@ -85,7 +85,7 @@ class ConditionallyResplitFileSetJob < ApplicationJob # @raise [ActiveFedora::ObjectNotFoundError] when the given FileSet's parent could not be found. # rubocop:disable Metrics/LineLength def perform(file_set_id:) - file_set = FileSetFinder.find(file_set_id: file_set_id) + file_set = FileSetFinder.find(file_set_id:) # We've logged this (see FileSetFinder.find) so we'll move along. return :file_set_not_found unless file_set @@ -106,7 +106,7 @@ def perform(file_set_id:) # this PDF. return :has_children if parent.child_work_ids.any? - IiifPrint::Jobs::RequestSplitPdfJob.perform_later(file_set: file_set, user: User.batch_user) + IiifPrint::Jobs::RequestSplitPdfJob.perform_later(file_set:, user: User.batch_user) :requesting_split end # rubocop:enable Metrics/LineLength @@ -119,10 +119,10 @@ class ConditionallyReingestFileSetJob < ApplicationJob # @param file_set_id [String] # @return [Symbol] A terse explanation of what was done with this job. def perform(file_set_id:) - file_set = FileSetFinder.find(file_set_id: file_set_id) + file_set = FileSetFinder.find(file_set_id:) # We've logged this (see FileSetFinder.find) so we'll move along. - return :file_set_not_found unless file_set + :file_set_not_found unless file_set # TODO: The file set does not appear to have a properly attached file. end diff --git a/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb b/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb index b33d060e..c006dbb5 100644 --- a/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb +++ b/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb @@ -15,19 +15,19 @@ module ChildWorksFromPdfJobDecorator # @param admin_set_id: [] # rubocop:disable Metrics/MethodLength def perform(id, pdf_paths, user, admin_set_id, *) - candidate_for_parency = IiifPrint.find_by(id: id) + candidate_for_parency = IiifPrint.find_by(id:) ## # We know that we have cases where parent_work is nil, this will definitely raise an # exception; which is fine because we were going to do it later anyway. @parent_work = if candidate_for_parency.work? - pdf_file_set = nil - candidate_for_parency - else - # We likely have a file set - pdf_file_set = candidate_for_parency - IiifPrint.parent_for(candidate_for_parency) - end + pdf_file_set = nil + candidate_for_parency + else + # We likely have a file set + pdf_file_set = candidate_for_parency + IiifPrint.parent_for(candidate_for_parency) + end @child_admin_set_id = admin_set_id child_model = @parent_work.iiif_print_config.pdf_split_child_model @@ -47,7 +47,7 @@ def perform(id, pdf_paths, user, admin_set_id, *) # @param parent_model: [] parent model # @param child_model: [] child model IiifPrint::Jobs::CreateRelationshipsJob.set(wait: 10.minutes).perform_later( - user: user, + user:, parent_id: @parent_work.id.to_s, parent_model: @parent_work.class.to_s, child_model: child_model.to_s @@ -84,7 +84,7 @@ def split_pdf(original_pdf_path, user, child_model, pdf_file_set) # @param [Hash] attributes attributes to apply to all works, including :model # @param [Hyrax::BatchCreateOperation] operation operation = Hyrax::BatchCreateOperation.create!( - user: user, + user:, operation_type: "PDF Batch Create" ) BatchCreateJob.perform_later(user, @@ -107,10 +107,10 @@ def prepare_import_data(original_pdf_path, image_files, user) file_id = create_uploaded_file(user, image_path).to_s child_title = IiifPrint.config.unique_child_title_generator_function.call( - original_pdf_path: original_pdf_path, - image_path: image_path, + original_pdf_path:, + image_path:, parent_work: @parent_work, - page_number: page_number, + page_number:, page_padding: number_of_digits(nbr: number_of_pages_in_pdf) ) @@ -118,7 +118,7 @@ def prepare_import_data(original_pdf_path, image_files, user) @uploaded_files << file_id @child_work_titles[file_id] = child_title # save child work info to create the member relationships - PendingRelationship.create!(child_title: child_title, + PendingRelationship.create!(child_title:, parent_id: @parent_work.id, child_order: child_title, parent_model: @parent_work.class, @@ -150,7 +150,7 @@ def create_uploaded_file(user, path) def attributes IiifPrint.config.child_work_attributes_function.call(parent_work: @parent_work, - admin_set_id: @child_admin_set_id) + admin_set_id: @child_admin_set_id) end # TODO: Does this method need to be configurable? diff --git a/app/jobs/index_plain_text_files_job.rb b/app/jobs/index_plain_text_files_job.rb index fbf1a386..39089d8d 100644 --- a/app/jobs/index_plain_text_files_job.rb +++ b/app/jobs/index_plain_text_files_job.rb @@ -13,47 +13,46 @@ class IndexPlainTextFilesJob < ApplicationJob # @see https://docs.ruby-lang.org/en/2.7.0/String.html#method-i-encode class One < ApplicationJob # @param file_set_id [String] + # rubocop:disable Metrics/BlockLength, Metrics/MethodLength def perform(account, file_set_id, time_to_live = 3, logger: IndexPlainTextFilesJob.default_logger) account.switch do - begin - file_set = FileSet.find(file_set_id) + file_set = FileSet.find(file_set_id) - if file_set.extracted_text.present? - logger.warn("#{self.class}: FileSet ID=\"#{file_set.id}\" (in #{account.cname}) has extracted text; "\ - "moving on.") - return true - end - - file = file_set.original_file + if file_set.extracted_text.present? + logger.warn("#{self.class}: FileSet ID=\"#{file_set.id}\" (in #{account.cname}) has extracted text; "\ + "moving on.") + return true + end - unless file - logger.error("#{self.class}: FileSet ID=\"#{file_set_id}\" expected to have an original_file; " \ - "however it was missing.") - return false - end + file = file_set.original_file - Adventist::TextFileTextExtractionService.assign_extracted_text( - file_set: file_set, - text: file.content, - original_file_name: Array(file.file_name).first - ) - logger.info("#{self.class}: FileSet ID=\"#{file_set_id}\" text extracted from plain text file.") - return true - rescue StandardError => e - if time_to_live.positive? - # It's possible we can recover from this, so we'll give it another go. - logger.warn("#{self.class}: FileSet ID=\"#{file_set_id}\" error for #{self.class}: #{e}. " \ - "Retries remaining #{time_to_live - 1}.") - One.perform_later(account, file_set_id, time_to_live - 1) - else - logger.error("#{self.class}: FileSet ID=\"#{file_set_id}\" error for #{self.class}: #{e}. " \ - "No retries remaining. Backtrace: #{e.backtrace}") - end + unless file + logger.error("#{self.class}: FileSet ID=\"#{file_set_id}\" expected to have an original_file; " \ + "however it was missing.") return false end + + Adventist::TextFileTextExtractionService.assign_extracted_text( + file_set:, + text: file.content, + original_file_name: Array(file.file_name).first + ) + logger.info("#{self.class}: FileSet ID=\"#{file_set_id}\" text extracted from plain text file.") + return true + rescue StandardError => e + if time_to_live.positive? + # It's possible we can recover from this, so we'll give it another go. + logger.warn("#{self.class}: FileSet ID=\"#{file_set_id}\" error for #{self.class}: #{e}. " \ + "Retries remaining #{time_to_live - 1}.") + One.perform_later(account, file_set_id, time_to_live - 1) + else + logger.error("#{self.class}: FileSet ID=\"#{file_set_id}\" error for #{self.class}: #{e}. " \ + "No retries remaining. Backtrace: #{e.backtrace}") + end + return false end end - # rubocop:enable Metrics/BlockLength + # rubocop:enable Metrics/BlockLength, Metrics/MethodLength end # @param account [Account] diff --git a/app/jobs/reload_pdfs_to_split_job.rb b/app/jobs/reload_pdfs_to_split_job.rb index ddceb83c..84cddb48 100644 --- a/app/jobs/reload_pdfs_to_split_job.rb +++ b/app/jobs/reload_pdfs_to_split_job.rb @@ -44,7 +44,7 @@ def process_work_type(work_type) @context = "worktype: #{work_type}, work: #{w.to_param}" # does this work have pdf filesets? - next unless w.file_sets&.map { |fs| fs.label.end_with?(".pdf") }.any? + next unless w.file_sets&.map { |fs| fs.label.end_with?(".pdf") }&.any? # does this work have any children? # For now we assume that if there are child works, it is correct. @@ -64,7 +64,7 @@ def do_cleanup!(work) @counter += 1 logger.info("✅ Enqueuing re-import for #{@context}.") - ReloadSinglePdfJob.perform_later(work: work) + ReloadSinglePdfJob.perform_later(work:) rescue StandardError => e logger.error("😈😈😈 Error: #{e.message} for #{@context}") raise e diff --git a/app/jobs/reload_single_pdf_job.rb b/app/jobs/reload_single_pdf_job.rb index 73075dba..7b439601 100644 --- a/app/jobs/reload_single_pdf_job.rb +++ b/app/jobs/reload_single_pdf_job.rb @@ -22,13 +22,14 @@ def perform(work:, logger: Rails.logger) # locate bulkrax work entry entry = Bulkrax::Entry.find_by(identifier: work.identifier.first) if entry - process_work(work: work, entry: entry) + process_work(work:, entry:) else @logger.info("🚫 Bulkrax::Entry not found for #{work.to_param}") raise BulkraxEntryNotFound end end + # rubocop:disable Metrics/MethodLength def process_work(work:, entry:) # destroy pending relationships & stray children pending_relationships = IiifPrint::PendingRelationship.where(parent_id: work.id) @@ -55,6 +56,7 @@ def process_work(work:, entry:) @logger.error("😈😈😈 Reimport error: #{e.message} for #{work.to_param}") raise e end + # rubocop:enable Metrics/MethodLength def destroy_potential_children_for(pending_relationships) pending_relationships.each do |pending| diff --git a/app/jobs/remove_account_relationships_job.rb b/app/jobs/remove_account_relationships_job.rb index 5e7d526d..896fc405 100644 --- a/app/jobs/remove_account_relationships_job.rb +++ b/app/jobs/remove_account_relationships_job.rb @@ -19,7 +19,7 @@ class ForImporterJob < ApplicationJob def perform(account, importer_id) account.switch do importer = Bulkrax::Importer.find(importer_id) - Bulkrax::RemoveRelationshipsForImporter.break_relationships_for!(importer: importer, with_progress_bar: false) + Bulkrax::RemoveRelationshipsForImporter.break_relationships_for!(importer:, with_progress_bar: false) end end end diff --git a/app/matchers/bulkrax/application_matcher_decorator.rb b/app/matchers/bulkrax/application_matcher_decorator.rb index 14bf742c..aa99a8ad 100644 --- a/app/matchers/bulkrax/application_matcher_decorator.rb +++ b/app/matchers/bulkrax/application_matcher_decorator.rb @@ -6,6 +6,7 @@ module Bulkrax module ApplicationMatcherDecorator # OVERRIDE Bulkrax 1.0.2 to override default_thumbnail + # rubocop:disable Metrics/MethodLength def process_parse # New parse methods will need to be added here parsed_fields = ['remote_files', @@ -28,6 +29,7 @@ def process_parse @result = send("parse_#{parser}", @result) end end + # rubocop:enable Metrics/MethodLength # OVERRIDE Bulkrax 1.0.2 to override default_thumbnail def parse_thumbnail_url(src) diff --git a/app/models/ability_decorator.rb b/app/models/ability_decorator.rb index e0805aea..f24ae169 100644 --- a/app/models/ability_decorator.rb +++ b/app/models/ability_decorator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AbilityDecorator ## # @api public diff --git a/app/models/collection_decorator.rb b/app/models/collection_decorator.rb index eaee9305..6f61bebe 100644 --- a/app/models/collection_decorator.rb +++ b/app/models/collection_decorator.rb @@ -3,34 +3,36 @@ module CollectionDecorator extend ActiveSupport::Concern + # rubocop:disable Metrics/BlockLength, Metrics/MethodLength class_methods do def additional_terms %i[abstract - alt - date - date_accepted - date_available - date_issued - date_published - date_submitted - department - doi - former_identifier - funder - issue_number - lat - location - long - managing_organisation - note - official_url - output_of - pagination - part_of - place_of_publication - publication_status].freeze + alt + date + date_accepted + date_available + date_issued + date_published + date_submitted + department + doi + former_identifier + funder + issue_number + lat + location + long + managing_organisation + note + official_url + output_of + pagination + part_of + place_of_publication + publication_status].freeze end end + # rubocop:enable Metrics/BlockLength, Metrics/MethodLength prepend OrderAlready.for(:creator) diff --git a/app/models/concerns/bulkrax/has_local_processing.rb b/app/models/concerns/bulkrax/has_local_processing.rb index f94446d6..101d0561 100644 --- a/app/models/concerns/bulkrax/has_local_processing.rb +++ b/app/models/concerns/bulkrax/has_local_processing.rb @@ -10,9 +10,11 @@ def add_local # ready to attach to the file_sets. If we proceed with using the thumbnail_url, we end up # attaching that thumbnail as it's own file_set. Which is likely non-desirous behavior. # - each_candidate_metadata_node do |node| - raw_metadata['thumbnail_url'] = node.content if node.name == 'thumbnail_url' - end if self.respond_to?(:each_candidate_metadata_node) + if respond_to?(:each_candidate_metadata_node) + each_candidate_metadata_node do |node| + raw_metadata['thumbnail_url'] = node.content if node.name == 'thumbnail_url' + end + end if parser.parser_fields['skip_thumbnail_url'] == "1" parsed_metadata.delete('thumbnail_url') diff --git a/app/models/concerns/slug_bug.rb b/app/models/concerns/slug_bug.rb index ad499fe6..474e66d9 100644 --- a/app/models/concerns/slug_bug.rb +++ b/app/models/concerns/slug_bug.rb @@ -23,11 +23,11 @@ def set_slug private - # Cribbed from https://gitlab.com/notch8/louisville-hyku/-/blob/main/app/models/custom_slugs/slug_behavior.rb#L14 - def remove_index_and_reindex - return unless slug.present? + # Cribbed from https://gitlab.com/notch8/louisville-hyku/-/blob/main/app/models/custom_slugs/slug_behavior.rb#L14 + def remove_index_and_reindex + return if slug.blank? - ActiveFedora::Base.remove_from_index!(id) - update_index - end + ActiveFedora::Base.remove_from_index!(id) + update_index + end end diff --git a/app/models/content_block_decorator.rb b/app/models/content_block_decorator.rb index bf8ca0e9..278ff864 100644 --- a/app/models/content_block_decorator.rb +++ b/app/models/content_block_decorator.rb @@ -26,7 +26,7 @@ def resources_page end def resources_page=(value) - resources_page.update(value: value) + resources_page.update(value:) end end diff --git a/app/parsers/bulkrax/oai_adventist_qdc_parser.rb b/app/parsers/bulkrax/oai_adventist_qdc_parser.rb index c0c4b599..3597aa1e 100644 --- a/app/parsers/bulkrax/oai_adventist_qdc_parser.rb +++ b/app/parsers/bulkrax/oai_adventist_qdc_parser.rb @@ -14,6 +14,7 @@ module Bulkrax # # From these assumptions we need to be mindful that our collection creation is different than # other OAI collection creations. + # rubocop:disable Metrics/ClassLength class OaiAdventistQdcParser < OaiQualifiedDcParser def entry_class Bulkrax::OaiAdventistQdcEntry @@ -120,7 +121,7 @@ def dispatch_creating_of_work_objects # rubocop:disable Style/Next if index >= offset break if limit_reached?(limit, count_towards_limit) - handle_creation_of(record: record, index: index) + handle_creation_of(record:, index:) self.count_towards_limit += 1 end # rubocop:enable Style/Next @@ -137,6 +138,7 @@ def dispatch_creating_of_work_objects # @param record [Oai::Record] # @param index [Integer] the index/position of the Oai::Record in the OAI feed. + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def handle_creation_of(record:, index:) return false unless record_has_source_identifier(record, index) @@ -149,14 +151,14 @@ def handle_creation_of(record:, index:) # # - What's the entry class # - What's the counter to increment - entry_class_type = entry_class_type_for(record: record) + entry_class_type = entry_class_type_for(record:) entry_class = send("#{entry_class_type}_entry_class") # We want to find or create the entry based on non-volatile information. Then we want to # capture the raw metadata for the record; capturing the raw metadata helps in debugging the # object. - new_entry = entry_class.where(importerexporter: importerexporter, identifier: identifier).first_or_create! + new_entry = entry_class.where(importerexporter:, identifier:).first_or_create! new_entry.update(raw_metadata: { record_level_xml: record._source.to_s }) # Note the parameters of the delete job and the import jobs are different. One assumes an @@ -185,6 +187,7 @@ def handle_creation_of(record:, index:) # entry_class_types tracked on that same index. counters[entry_class_type] += 1 end + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength # @param record [Oai::Record] # @param index [Integer] the positional index of the record in the OAI feed. @@ -206,6 +209,7 @@ def record_has_source_identifier(record, index) # @param record [Oai::Record] # @return [Symbol] either :collection, :file_set, or :work + # rubocop:disable Metrics/MethodLength def entry_class_type_for(record:) entry_class_type = nil model_field_mappings.each do |model_mapping| @@ -224,4 +228,5 @@ def entry_class_type_for(record:) entry_class_type || :work end end + # rubocop:enable Metrics/ClassLength, Metrics/MethodLength end diff --git a/app/search_builders/adv_search_builder.rb b/app/search_builders/adv_search_builder.rb index b0db273f..8baa89ed 100644 --- a/app/search_builders/adv_search_builder.rb +++ b/app/search_builders/adv_search_builder.rb @@ -19,8 +19,7 @@ def facets_for_advanced_search_form(solr_p) solr_p["rows"] = "0" # Anything set in config as a literal - if blacklight_config.advanced_search[:form_solr_parameters] - solr_p.merge!(blacklight_config.advanced_search[:form_solr_parameters]) - end + return unless blacklight_config.advanced_search[:form_solr_parameters] + solr_p.merge!(blacklight_config.advanced_search[:form_solr_parameters]) end end diff --git a/app/services/adventist/text_file_text_extraction_service.rb b/app/services/adventist/text_file_text_extraction_service.rb index f60483db..7e8b71a3 100644 --- a/app/services/adventist/text_file_text_extraction_service.rb +++ b/app/services/adventist/text_file_text_extraction_service.rb @@ -54,7 +54,7 @@ def cleanup_derivatives; end # Hyrax::FileSetDerivatives#extract_full_text def create_derivatives(filename) self.class.assign_extracted_text( - file_set: file_set, + file_set:, text: File.read(filename), original_file_name: filename ) @@ -66,7 +66,7 @@ def derivative_url(_destination_name) end def valid? - return true if VALID_MIME_TYPES.detect do |valid_mime_type| + true if VALID_MIME_TYPES.detect do |valid_mime_type| # Because character encoding may be part of the mime_type. So we want both "text/plain" and # "text/plain;charset=UTF-8" to be a valid type. valid_mime_type.start_with?(mime_type) diff --git a/app/services/daily_solr_content_check_service.rb b/app/services/daily_solr_content_check_service.rb index 836eba96..c935ce0a 100644 --- a/app/services/daily_solr_content_check_service.rb +++ b/app/services/daily_solr_content_check_service.rb @@ -16,11 +16,12 @@ class DailySolrContentCheckService # @note Why all the logging? One concern is how this query might affect performance. And with # each logged moment we have a timestamp with which we can compare the system resource # utilization. + # rubocop:disable Metrics/MethodLength def self.call(buffer: STDOUT, delimiter: "\t", logger: Rails.logger, fields: FIELDS, query: QUERY) logger.info "Starting #{self}.call" buffer.puts "cname#{delimiter}#{fields.join(delimiter)}" - Account.all.each do |account| + Account.all.find_each do |account| account.switch do logger.info "Begin #{self}.call loop for #{account.cname}" index = 0 @@ -37,4 +38,5 @@ def self.call(buffer: STDOUT, delimiter: "\t", logger: Rails.logger, fields: FIE end logger.info "Finishing #{self}.call" end + # rubocop:enable Metrics/MethodLength end diff --git a/app/services/hyrax/custom_queries/find_by_slug.rb b/app/services/hyrax/custom_queries/find_by_slug.rb index 6c455589..4bd5e3a2 100644 --- a/app/services/hyrax/custom_queries/find_by_slug.rb +++ b/app/services/hyrax/custom_queries/find_by_slug.rb @@ -6,20 +6,20 @@ class FindBySlug def self.queries [:find_by_slug] end - + def initialize(query_service:) @query_service = query_service end - + attr_reader :query_service delegate :resource_factory, to: :query_service - + def find_by_slug(slug:) - Hyrax.query_service.orm_class.find_by_sql(([find_by_slug_query, "\"#{slug.to_s}\""])).lazy.map do |object| - resource_factory.to_resource(object: object) + Hyrax.query_service.orm_class.find_by_sql([find_by_slug_query, "\"#{slug}\""]).lazy.map do |object| + resource_factory.to_resource(object:) end.first end - + def find_by_slug_query <<-SQL SELECT * FROM orm_resources diff --git a/app/services/hyrax/work_uploads_handler_decorator.rb b/app/services/hyrax/work_uploads_handler_decorator.rb index 2c1bfc1f..dd4d33b5 100644 --- a/app/services/hyrax/work_uploads_handler_decorator.rb +++ b/app/services/hyrax/work_uploads_handler_decorator.rb @@ -16,8 +16,7 @@ def file_set_args(file) date_modified: Hyrax::TimeService.time_in_utc, label: file.uploader.filename, title: file.uploader.filename, - override_default_thumbnail: file_set_extra_params(file)["override_default_thumbnail"] - } + override_default_thumbnail: file_set_extra_params(file)["override_default_thumbnail"] } end end end diff --git a/app/services/iiif_print/manifest_builder_service_behavior_decorator.rb b/app/services/iiif_print/manifest_builder_service_behavior_decorator.rb index 16018e24..54fb1eda 100644 --- a/app/services/iiif_print/manifest_builder_service_behavior_decorator.rb +++ b/app/services/iiif_print/manifest_builder_service_behavior_decorator.rb @@ -4,7 +4,7 @@ module HykuKnapsack module ManifestBuilderServiceDecorator def build_manifest(presenter:) returning_hash = super - returning_hash['rendering'] = rendering(presenter: presenter) + returning_hash['rendering'] = rendering(presenter:) returning_hash end @@ -19,7 +19,7 @@ def sanitize_v2(hash:, presenter:, solr_doc_hits:) sequence['canvases']&.each do |canvas| canvas['label'] = sanitize_label(canvas['label']) - apply_metadata_to_canvas(canvas: canvas, presenter: presenter, solr_doc_hits: solr_doc_hits) + apply_metadata_to_canvas(canvas:, presenter:, solr_doc_hits:) end end hash @@ -27,28 +27,28 @@ def sanitize_v2(hash:, presenter:, solr_doc_hits:) private - def rendering(presenter:) - model = presenter.solr_document['has_model_ssim'].first - # Our current presenter is a IiifManifestPresenter, which doesn't have the file_set_presenters we need. - # So we create a Hyrax presenter for the model, and use that to get the file_set_presenters. - hyrax_presenter = "Hyrax::#{model}Presenter".constantize.new(presenter, presenter.ability) - file_set_presenters = hyrax_presenter.file_set_presenters.reject { |fsp| fsp.mime_type&.include?('image') } - - file_set_presenters.map do |fsp| - { - # Yes, we are using `#send` because `#hostname` is a private method, though I think it's okay here - "@id": Hyrax::Engine.routes.url_helpers.download_url(fsp.id, - host: presenter.send(:hostname), - protocol: 'https'), - "label": fsp.label, - "format": fsp.mime_type - } - end + def rendering(presenter:) + model = presenter.solr_document['has_model_ssim'].first + # Our current presenter is a IiifManifestPresenter, which doesn't have the file_set_presenters we need. + # So we create a Hyrax presenter for the model, and use that to get the file_set_presenters. + hyrax_presenter = "Hyrax::#{model}Presenter".constantize.new(presenter, presenter.ability) + file_set_presenters = hyrax_presenter.file_set_presenters.reject { |fsp| fsp.mime_type&.include?('image') } + + file_set_presenters.map do |fsp| + { + # Yes, we are using `#send` because `#hostname` is a private method, though I think it's okay here + "@id": Hyrax::Engine.routes.url_helpers.download_url(fsp.id, + host: presenter.send(:hostname), + protocol: 'https'), + "label": fsp.label, + "format": fsp.mime_type + } end + end - def sanitize_label(label) - CGI.unescapeHTML(sanitize_value(label)) - end + def sanitize_label(label) + CGI.unescapeHTML(sanitize_value(label)) + end end end diff --git a/app/services/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter.rb b/app/services/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter.rb index 1b5115e1..c14ff75f 100644 --- a/app/services/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter.rb +++ b/app/services/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter.rb @@ -31,7 +31,7 @@ def self.call(path, splitter: DerivativeRodeoSplitter, suffixes: CreateDerivativesJobDecorator::NON_ARCHIVAL_PDF_SUFFIXES, **args) - return [] unless AdventistPagesToJpgsSplitter.split_this?(path: path, suffixes: suffixes) + return [] unless AdventistPagesToJpgsSplitter.split_this?(path:, suffixes:) splitter.call(path, **args) end diff --git a/lib/adl/transactions/steps/set_slug.rb b/lib/adl/transactions/steps/set_slug.rb index 9d1d1625..a5089815 100644 --- a/lib/adl/transactions/steps/set_slug.rb +++ b/lib/adl/transactions/steps/set_slug.rb @@ -18,7 +18,7 @@ def call(change_set) # 2) It also apparently happens in some situations where data existed prior to the slug logic # This query finds everything indexed by the original object's id. The new index will have id: slug. original_id = change_set.id.to_s - unless original_id.blank? + if original_id.present? Hyrax::SolrService.delete_by_query('id:"' + original_id + '" OR resource_id_ssi:"' + original_id + '" OR fedora_id_ssi:"' + original_id + '"') Hyrax::SolrService.commit end diff --git a/lib/dog_biscuits/blacklight/commands.rb b/lib/dog_biscuits/blacklight/commands.rb index 6c55c7fd..f4759f1b 100644 --- a/lib/dog_biscuits/blacklight/commands.rb +++ b/lib/dog_biscuits/blacklight/commands.rb @@ -9,110 +9,112 @@ module Commands include DogBiscuits::Solr::IndexTypes + # rubocop:disable Metrics/BlockLength class_methods do private - def decode_name_and_options(name, options = {}) - actual_name = name.keys.first - values = name.values.first - labelled_name = values[:name] || actual_name - index_type = values[:as] || :stored_searchable - solr_options = values[:type] && [{ type: values[:type] }] || nil - options.merge!(values[:options] || {}) - [actual_name, labelled_name, index_type, solr_options, options] - end - - def default_label(name) - I18n.t('dog_biscuits.fields.' + name.to_s) - end - - def default_label_options(name) - { label: default_label(name) } - end - - def default_index_options(name, index_type = :facetable) - { itemprop: name, link_to_search: send("#{index_type}_name", name) } - end - - def index_options(name, mapping) - return {} unless mapping - opts = {} - mapping[:index]&.each do |opt| - opts[opt.keys.first] = index_option_value(name, opt.keys.first, opt[opt.keys.first]) - end - opts[:itemprop] = mapping[:schema_org][:property] if mapping[:schema_org] - opts[:helper_method] = mapping[:helper_method] if mapping[:helper_method] - { options: opts } - end - - def index_option_value(name, key, value) - if key == :link_to_search && value == true - index_type = :facetable - send("#{index_type}_name", name) - else - value - end - end - - def send_to_configuration(config, name, config_type, default_index_type, options = {}) - name, label_name, index_type, solr_options, options = if name.is_a?(Hash) - decode_name_and_options(name, options) - else - [name, name, default_index_type, nil, options] - end - begin - config.send("add_#{config_type}", send("#{index_type}_name", name, *solr_options), default_label_options(label_name).merge(options)) - rescue ArgumentError - Rails.logger("solr_options are: #{solr_options.inspect}") - raise - end - end - - def add_labelled_facet_field(config, name, options) - send_to_configuration(config, name, :facet_field, :facetable, options) - end - - def add_labelled_index_field(config, name, options = {}) - send_to_configuration(config, name, :index_field, :stored_searchable, options) - end - - def add_labelled_show_field(config, name, options = {}) - send_to_configuration(config, name, :show_field, :stored_searchable, options) - end - - def add_solr_search_field(config, name, options = {}) - name, label_name, index_type, solr_options, _options = if name.is_a?(Hash) - decode_name_and_options(name, options) - else - [name, name, :stored_searchable, options] - end - local_params_solr_name = send("#{index_type}_name", name, *solr_options) - config.add_search_field(name.to_s) do |field| - field.label = default_label(label_name) - field.solr_local_parameters = { qf: local_params_solr_name, pf: local_params_solr_name } - end - end - - def add_facet_field(config, names, options = { limit: 5 }) - names.each { |name| add_labelled_facet_field(config, name, options) } - end - - def add_index_field(config, names) - names.each { |name| add_labelled_index_field(config, name) } - end - - def add_show_field(config, names) - names.each { |name| add_labelled_show_field(config, name) } - end - - def add_search_field(config, names) - names.each { |name| add_solr_search_field(config, name) } - end - - def to_searchable_names_field_list(names) - names.map { |name| stored_searchable_name(name) }.join(' ') - end + def decode_name_and_options(name, options = {}) + actual_name = name.keys.first + values = name.values.first + labelled_name = values[:name] || actual_name + index_type = values[:as] || :stored_searchable + solr_options = values[:type] && [{ type: values[:type] }] || nil + options.merge!(values[:options] || {}) + [actual_name, labelled_name, index_type, solr_options, options] + end + + def default_label(name) + I18n.t('dog_biscuits.fields.' + name.to_s) + end + + def default_label_options(name) + { label: default_label(name) } + end + + def default_index_options(name, index_type = :facetable) + { itemprop: name, link_to_search: send("#{index_type}_name", name) } + end + + def index_options(name, mapping) + return {} unless mapping + opts = {} + mapping[:index]&.each do |opt| + opts[opt.keys.first] = index_option_value(name, opt.keys.first, opt[opt.keys.first]) + end + opts[:itemprop] = mapping[:schema_org][:property] if mapping[:schema_org] + opts[:helper_method] = mapping[:helper_method] if mapping[:helper_method] + { options: opts } + end + + def index_option_value(name, key, value) + if key == :link_to_search && value == true + index_type = :facetable + send("#{index_type}_name", name) + else + value + end + end + + def send_to_configuration(config, name, config_type, default_index_type, options = {}) + name, label_name, index_type, solr_options, options = if name.is_a?(Hash) + decode_name_and_options(name, options) + else + [name, name, default_index_type, nil, options] + end + begin + config.send("add_#{config_type}", send("#{index_type}_name", name, *solr_options), default_label_options(label_name).merge(options)) + rescue ArgumentError + Rails.logger("solr_options are: #{solr_options.inspect}") + raise + end + end + + def add_labelled_facet_field(config, name, options) + send_to_configuration(config, name, :facet_field, :facetable, options) + end + + def add_labelled_index_field(config, name, options = {}) + send_to_configuration(config, name, :index_field, :stored_searchable, options) + end + + def add_labelled_show_field(config, name, options = {}) + send_to_configuration(config, name, :show_field, :stored_searchable, options) + end + + def add_solr_search_field(config, name, options = {}) + name, label_name, index_type, solr_options, _options = if name.is_a?(Hash) + decode_name_and_options(name, options) + else + [name, name, :stored_searchable, options] + end + local_params_solr_name = send("#{index_type}_name", name, *solr_options) + config.add_search_field(name.to_s) do |field| + field.label = default_label(label_name) + field.solr_local_parameters = { qf: local_params_solr_name, pf: local_params_solr_name } + end + end + + def add_facet_field(config, names, options = { limit: 5 }) + names.each { |name| add_labelled_facet_field(config, name, options) } + end + + def add_index_field(config, names) + names.each { |name| add_labelled_index_field(config, name) } + end + + def add_show_field(config, names) + names.each { |name| add_labelled_show_field(config, name) } + end + + def add_search_field(config, names) + names.each { |name| add_solr_search_field(config, name) } + end + + def to_searchable_names_field_list(names) + names.map { |name| stored_searchable_name(name) }.join(' ') + end end + # rubocop:enable Metrics/BlockLength end end end diff --git a/lib/dog_biscuits/importers/authority.rb b/lib/dog_biscuits/importers/authority.rb index 18778715..21954c0d 100644 --- a/lib/dog_biscuits/importers/authority.rb +++ b/lib/dog_biscuits/importers/authority.rb @@ -26,40 +26,40 @@ def create_record(label, uri = nil) uri = construct_uri(label) if uri.blank? Qa::LocalAuthorityEntry.create(local_authority: @authority, label: cleanup_label(label), - uri: uri) + uri:) rescue ActiveRecord::RecordNotUnique Rails.logger.warn("Duplicate record: #{label}") end private - # Replace & with & - # - # @param label [String] the label for cleanup - # @return [String] cleaned up label - def cleanup_label(label) - label.gsub('&', '&') - end + # Replace & with & + # + # @param label [String] the label for cleanup + # @return [String] cleaned up label + def cleanup_label(label) + label.gsub('&', '&') + end - # Create a version of the label for use as a uri: - # replace all non-alphanumeric characters with whitespace - # trim to 50 characters and replace whitespace with a dash - # - # @param label [String] the label for uri-ification - # @return [String] uri-ified label - def uri_ifiy_label(label) - cleanup_label(label).gsub(/[^\w\s\d]/, ' ')[0..50].parameterize - end + # Create a version of the label for use as a uri: + # replace all non-alphanumeric characters with whitespace + # trim to 50 characters and replace whitespace with a dash + # + # @param label [String] the label for uri-ification + # @return [String] uri-ified label + def uri_ifiy_label(label) + cleanup_label(label).gsub(/[^\w\s\d]/, ' ')[0..50].parameterize + end - # Create a default URI for the term - # - # @param label [String] the label for cleanup - # @return [String] cleaned up label - def construct_uri(label) - hostname = `hostname`.delete("\n") - hostname = "example.com" if hostname.include?('localhost') - "http://#{hostname}/#{@authority_name}/#{uri_ifiy_label(label)}" - end + # Create a default URI for the term + # + # @param label [String] the label for cleanup + # @return [String] cleaned up label + def construct_uri(label) + hostname = `hostname`.delete("\n") + hostname = "example.com" if hostname.include?('localhost') + "http://#{hostname}/#{@authority_name}/#{uri_ifiy_label(label)}" + end end end end diff --git a/lib/dog_biscuits/indexers/concerns/indexes_common.rb b/lib/dog_biscuits/indexers/concerns/indexes_common.rb index daf0f896..4ed8e06f 100644 --- a/lib/dog_biscuits/indexers/concerns/indexes_common.rb +++ b/lib/dog_biscuits/indexers/concerns/indexes_common.rb @@ -14,6 +14,7 @@ def generate_solr_document # Index different contributor types (relators, eg. editor, advisor) into contributor # Index the contributor type itself + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def solr_doc_for_contributors(solr_doc) if respond_to? :contributors_to_index contributors_to_index.each do |v| @@ -36,11 +37,12 @@ def solr_doc_for_contributors(solr_doc) end end end + # rubocop:enable Metrics/AbcSize, Metrics/MethodLength # Extract years from all date fields and index into 'date_range_sim' def solr_doc_for_dates(solr_doc) DogBiscuits.config.date_properties.each do |d| - next unless (object.respond_to?(d) && object.send(d).respond_to?(:each)) + next unless object.respond_to?(d) && object.send(d).respond_to?(:each) object.send(d).each do |dd| dd.to_s.scan(/\b\d{4}\b/).each do |year| if solr_doc['date_range_sim'] diff --git a/lib/dog_biscuits/services/terms_service.rb b/lib/dog_biscuits/services/terms_service.rb index f51e888a..6cf45fde 100755 --- a/lib/dog_biscuits/services/terms_service.rb +++ b/lib/dog_biscuits/services/terms_service.rb @@ -1,10 +1,13 @@ # frozen_string_literal: true module DogBiscuits + # rubocop:disable Metrics/ClassLength class TermsService < Hyrax::QaSelectService + # rubocop:disable Lint/MissingSuper def initialize(_authority = nil) @authority = self end + # rubocop:enable Lint/MissingSuper # Returns the ConceptScheme id for a given Scheme name # @@ -112,51 +115,52 @@ def select_all_options private - # Reformats the data received from the service - # - # @param response [SolrResponse] for the Solr query - # @return [Hash] authority data - def parse_authority_response(response) - response['response']['docs'].map do |result| - hash = { - id: result['id'] - } + # Reformats the data received from the service + # + # @param response [SolrResponse] for the Solr query + # @return [Hash] authority data + def parse_authority_response(response) + response['response']['docs'].map do |result| + hash = { + id: result['id'] + } - hash[:label] = result['preflabel_tesim'].join if result['preflabel_tesim'] - hash[:definition] = result['definition_tesim'].join if result['definition_tesim'] + hash[:label] = result['preflabel_tesim'].join if result['preflabel_tesim'] + hash[:definition] = result['definition_tesim'].join if result['definition_tesim'] - # Only add broader where it exists (ie. subjects) - # Assumes only one broader - if result['broader_ssim'] - hash[:broader_id] = result['broader_ssim'].join - hash[:broader_label] = find_label_string(result['broader_ssim'].join).join - end - hash + # Only add broader where it exists (ie. subjects) + # Assumes only one broader + if result['broader_ssim'] + hash[:broader_id] = result['broader_ssim'].join + hash[:broader_label] = find_label_string(result['broader_ssim'].join).join end + hash end + end - # Parse the id from the solr response - # - # @param response [SolrResponse] for the Solr query - # @return [String] id - def parse_terms_id_response(response) - id = '' - response['response']['docs'].map do |result| - id = result['id'] - end - id + # Parse the id from the solr response + # + # @param response [SolrResponse] for the Solr query + # @return [String] id + def parse_terms_id_response(response) + id = '' + response['response']['docs'].map do |result| + id = result['id'] end + id + end - # Parse the preflabel from the solr response - # - # @param response [SolrResponse] for the Solr query - # @return [String] preflabel - def parse_string(response) - str = '' - response['response']['docs'].map do |result| - str = result['preflabel_tesim'] - end - str + # Parse the preflabel from the solr response + # + # @param response [SolrResponse] for the Solr query + # @return [String] preflabel + def parse_string(response) + str = '' + response['response']['docs'].map do |result| + str = result['preflabel_tesim'] end + str + end end + # rubocop:enable Metrics/ClassLength end diff --git a/lib/dog_biscuits/vocab/borthwick_registers.rb b/lib/dog_biscuits/vocab/borthwick_registers.rb index ff6d35a2..343162ce 100755 --- a/lib/dog_biscuits/vocab/borthwick_registers.rb +++ b/lib/dog_biscuits/vocab/borthwick_registers.rb @@ -3,6 +3,7 @@ require 'rdf' module DogBiscuits module Vocab + # rubocop:disable Metrics/ClassLength class BorthwickRegisters < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/borthwick-registers#') # Class definitions term :SingleDate, @@ -317,5 +318,6 @@ class BorthwickRegisters < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/bo label: 'Borthwick Registers', 'owl:versionInfo' => '' end + # rubocop:enable Metrics/ClassLength end end diff --git a/lib/dog_biscuits/vocab/generic.rb b/lib/dog_biscuits/vocab/generic.rb index 0099dff9..542a2ba7 100755 --- a/lib/dog_biscuits/vocab/generic.rb +++ b/lib/dog_biscuits/vocab/generic.rb @@ -3,6 +3,7 @@ require 'rdf' module DogBiscuits module Vocab + # rubocop:disable Metrics/ClassLength class Generic < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/generic#') # Class definitions term :GenericWork, @@ -200,5 +201,6 @@ class Generic < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/generic#') label: 'Generic', 'owl:versionInfo' => '' end + # rubocop:enable Metrics/ClassLength end end diff --git a/lib/dog_biscuits/vocab/oais_archivematica.rb b/lib/dog_biscuits/vocab/oais_archivematica.rb index bda3933c..7b5fa874 100755 --- a/lib/dog_biscuits/vocab/oais_archivematica.rb +++ b/lib/dog_biscuits/vocab/oais_archivematica.rb @@ -3,6 +3,7 @@ require 'rdf' module DogBiscuits module Vocab + # rubocop:disable Metrics/ClassLength class OaisArchivematica < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/oais-archivematica#') # Class definitions term :DisseminationInformationPackage, @@ -112,5 +113,6 @@ class OaisArchivematica < RDF::Vocabulary('http://dlib.york.ac.uk/ontologies/oai label: 'Generic', 'owl:versionInfo' => '' end + # rubocop:enable Metrics/ClassLength end end diff --git a/lib/hyku_knapsack/engine.rb b/lib/hyku_knapsack/engine.rb index 45bf1904..6c8e30fd 100644 --- a/lib/hyku_knapsack/engine.rb +++ b/lib/hyku_knapsack/engine.rb @@ -45,6 +45,7 @@ def self.load_translations! end end + # rubocop:disable Metrics/BlockLength config.after_initialize do # need collection model first collection_decorator = HykuKnapsack::Engine.root.join("app", "models", "collection_decorator.rb").to_s @@ -90,8 +91,8 @@ def self.load_translations! DerivativeRodeo::Generators::HocrGenerator.additional_tessearct_options = "-l eng_best" # See: https://github.com/scientist-softserv/adventist-dl/issues/676 IiifPrint::DerivativeRodeoService.named_derivatives_and_generators_filter = - lambda do |file_set:, filename:, named_derivatives_and_generators:| - named_derivatives_and_generators.reject do |named_derivative, generators| + lambda do |_file_set:, filename:, named_derivatives_and_generators:| + named_derivatives_and_generators.reject do |named_derivative, _generators| named_derivative != :thumbnail && filename.downcase.ends_with?(HykuKnapsack::Engine::THUMBNAIL_FILE_SUFFIX) end end @@ -110,13 +111,14 @@ def self.load_translations! # we don't, we'll use local files (which almost certainly will fail). This means we'd be locally # using the derivative rodeo's splitting process (which should work without a preprocess lcoation). # rubocop:disable Metrics/LineLength - if DerivativeRodeo.config.aws_s3_access_key_id.present? && DerivativeRodeo.config.aws_s3_secret_access_key.present? - IiifPrint::DerivativeRodeoService.preprocessed_location_adapter_name = 's3' - else - IiifPrint::DerivativeRodeoService.preprocessed_location_adapter_name = 'file' - end + IiifPrint::DerivativeRodeoService.preprocessed_location_adapter_name = if DerivativeRodeo.config.aws_s3_access_key_id.present? && DerivativeRodeo.config.aws_s3_secret_access_key.present? + 's3' + else + 'file' + end # rubocop:enable Metrics/LineLength end end + # rubocop:enable Metrics/BlockLength end end diff --git a/lib/oai/provider/metadata_format/adl_dublin_core.rb b/lib/oai/provider/metadata_format/adl_dublin_core.rb index 5d5dbe9f..0968f280 100644 --- a/lib/oai/provider/metadata_format/adl_dublin_core.rb +++ b/lib/oai/provider/metadata_format/adl_dublin_core.rb @@ -4,6 +4,7 @@ module OAI module Provider module MetadataFormat class AdlDublinCore < OAI::Provider::Metadata::Format + # rubocop:disable Lint/MissingSuper def initialize @prefix = 'oai_adl' @schema = 'http://dublincore.org/schemas/xmls/qdc/dcterms.xsd' @@ -19,8 +20,10 @@ def initialize remote_url resource_type rights_statement source subject title thumbnail_url volume_number work_type] end + # rubocop:enable Lint/MissingSuper # Override to strip namespace and header out + # rubocop:disable Metrics/MethodLength def encode(model, record) xml = Builder::XmlMarkup.new map = model.respond_to?("map_#{prefix}") ? model.send("map_#{prefix}") : {} @@ -38,6 +41,7 @@ def encode(model, record) end xml.target! end + # rubocop:enable Metrics/MethodLength def header_specification { diff --git a/lib/oai/provider/metadata_format/qualified_dublin_core.rb b/lib/oai/provider/metadata_format/qualified_dublin_core.rb index 6c7713f5..85c25955 100644 --- a/lib/oai/provider/metadata_format/qualified_dublin_core.rb +++ b/lib/oai/provider/metadata_format/qualified_dublin_core.rb @@ -4,6 +4,7 @@ module OAI module Provider module MetadataFormat class QualifiedDublinCore < OAI::Provider::Metadata::Format + # rubocop:disable Lint/MissingSuper def initialize @prefix = 'oai_qdc' @schema = 'http://dublincore.org/schemas/xmls/qdc/dcterms.xsd' @@ -17,6 +18,7 @@ def initialize spatial language isPartOf tableOfContents temporal bibliographicCitation relation isReferencedBy hasPart isVersionOf extent format] end + # rubocop:enable Lint/MissingSuper def header_specification { diff --git a/lib/oai/provider/model_decorator.rb b/lib/oai/provider/model_decorator.rb index 0aa8c29e..2e52969e 100644 --- a/lib/oai/provider/model_decorator.rb +++ b/lib/oai/provider/model_decorator.rb @@ -4,6 +4,7 @@ module OAI module Provider module ModelDecorator # Map Qualified Dublin Core (Terms) fields to Oregon Digital fields + # rubocop:disable Metrics/MethodLength def map_oai_qdc { title: :title, alternative: :alternative_title, @@ -39,6 +40,7 @@ def map_oai_qdc part: :part, volume: :volume } end + # rubocop:enable Metrics/MethodLength # rubocop:disable Metrics/MethodLength def map_oai_adl diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index bf2db2be..af1988d7 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -3,7 +3,7 @@ namespace :maintenance do desc "Index each tenants plain text files" task index_plain_text_file_content: :environment do - Account.all.each do |account| + Account.all.find_each do |account| IndexPlainTextFilesJob.perform_later(account) end end diff --git a/sdapi_ingest_scripts/jobs/add_works_to_collections_job.rb b/sdapi_ingest_scripts/jobs/add_works_to_collections_job.rb index a3a58a42..5e951841 100644 --- a/sdapi_ingest_scripts/jobs/add_works_to_collections_job.rb +++ b/sdapi_ingest_scripts/jobs/add_works_to_collections_job.rb @@ -13,7 +13,7 @@ def perform CSV.parse(csv_data, headers: true) do |row| record_data = row.to_hash.symbolize_keys begin - ConvertToRelationshipJob.perform_later(record_data: record_data) + ConvertToRelationshipJob.perform_later(record_data:) rescue StandardError => e Rails.logger.error("😈😈😈 Error: #{e.message} for #{record_data[:identifier]}") Raven.capture_exception(e) diff --git a/sdapi_ingest_scripts/jobs/collection_membership_job.rb b/sdapi_ingest_scripts/jobs/collection_membership_job.rb index 68845b73..67e75a94 100644 --- a/sdapi_ingest_scripts/jobs/collection_membership_job.rb +++ b/sdapi_ingest_scripts/jobs/collection_membership_job.rb @@ -15,6 +15,7 @@ class CollectionMembershipJob < ApplicationJob ].freeze # rubocop:enable Metrics/LineLength + # rubocop:disable Metrics/MethodLength def perform(work_type: 'JournalArticle', removed_coll_ids: COLLECTIONS_TO_REMOVE) wk_count = 0 @@ -38,6 +39,7 @@ def perform(work_type: 'JournalArticle', wk_updated += 1 end + # rubocop:enable Metrics/MethodLength # rubocop:disable Metrics/LineLength Rails.logger.info("💜💜💜 Collection updates for work type #{work_type}: #{wk_count} processed, #{wk_updated} updated.") diff --git a/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb b/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb index bfc31f2e..b9ce927c 100644 --- a/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb +++ b/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb @@ -36,6 +36,7 @@ def perform(importer_id:, last_run_id: nil, error_classes: [], logger: Rails.log attr_reader :importer, :last_run, :new_run, :logger, :error_classes + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def do_it! reimport_logging_context = "#{importer.class} ID=#{importer.id} with #{last_run.class} ID=#{last_run.id}" @@ -86,4 +87,5 @@ def do_it! logger.info("Finished submitting re-imports for #{reimport_logging_context}.") end + # rubocop:disable Metrics/AbcSize, Metrics/MethodLength end diff --git a/spec/bulkrax/entry_spec_helper.rb b/spec/bulkrax/entry_spec_helper.rb index 81399147..fb020ac2 100644 --- a/spec/bulkrax/entry_spec_helper.rb +++ b/spec/bulkrax/entry_spec_helper.rb @@ -32,7 +32,7 @@ module EntrySpecHelper # # @return [Bulkrax::Entry] def self.entry_for(data:, identifier:, parser_class_name:, **options) - importer = importer_for(parser_class_name: parser_class_name, **options) + importer = importer_for(parser_class_name:, **options) # Using an instance of the entry_class to dispatch to different entry_for_dispatch = options.fetch(:entry_class) { importer.parser.entry_class }.new @@ -47,7 +47,7 @@ def self.entry_for(data:, identifier:, parser_class_name:, **options) # Yes, we'll raise an error if we didn't find a corresponding key. And that's okay. symbol = entry_class_to_symbol_map.fetch(key) - send("build_#{symbol}_entry_for", importer: importer, identifier: identifier, data: data, **options) + send("build_#{symbol}_entry_for", importer:, identifier:, data:, **options) end DEFAULT_ENTRY_CLASS_TO_SYMBOL_MAP = { @@ -71,9 +71,7 @@ def self.importer_for(parser_class_name:, parser_fields: {}, **options) # Ideally, we could pass in the field_mapping. However, there is logic that ignores the # parser's field_mapping and directly asks for Bulkrax's field_mapping (e.g. model_mapping # method). - if options.key?(:importer_field_mapping) - Rails.logger.warn("You passed :importer_field_mapping as an option. This may not fully work as desired.") - end + Rails.logger.warn("You passed :importer_field_mapping as an option. This may not fully work as desired.") if options.key?(:importer_field_mapping) Bulkrax::Importer.new( name: options.fetch(:importer_name, "Test importer for identifier"), admin_set_id: options.fetch(:importer_admin_set_id, "admin_set/default"), @@ -81,7 +79,7 @@ def self.importer_for(parser_class_name:, parser_fields: {}, **options) limit: options.fetch(:importer_limits, 1), parser_klass: parser_class_name, field_mapping: options.fetch(:importer_field_mappings) { Bulkrax.field_mappings.fetch(parser_class_name) }, - parser_fields: parser_fields + parser_fields: ) end private_class_method :importer_for @@ -99,7 +97,7 @@ def self.importer_for(parser_class_name:, parser_fields: {}, **options) def self.build_csv_entry_for(importer:, data:, identifier:, **_options) options.fetch(:entry_class) { importer.parser.entry_class }.new( importerexporter: importer, - identifier: identifier, + identifier:, raw_metadata: data ) end @@ -124,10 +122,10 @@ def self.build_oai_entry_for(importer:, data:, identifier:, **options) } options.fetch(:entry_class) { importer.parser.entry_class }.new( - raw_record: raw_record, + raw_record:, importerexporter: importer, - identifier: identifier, - raw_metadata: raw_metadata + identifier:, + raw_metadata: ) end @@ -147,8 +145,8 @@ def self.build_xml_entry_for(importer:, data:, identifier:, **options) options.fetch(:entry_class) { importer.parser.entry_class }.new( importerexporter: importer, - identifier: identifier, - raw_metadata: raw_metadata + identifier:, + raw_metadata: ) end end diff --git a/spec/features/create_conference_item_spec.rb b/spec/features/create_conference_item_spec.rb index 6d7ed45c..7948a32a 100644 --- a/spec/features/create_conference_item_spec.rb +++ b/spec/features/create_conference_item_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/create_dataset_spec.rb b/spec/features/create_dataset_spec.rb index 5828dd72..df3b2b8d 100644 --- a/spec/features/create_dataset_spec.rb +++ b/spec/features/create_dataset_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/create_exam_paper_spec.rb b/spec/features/create_exam_paper_spec.rb index f47a3467..d3302320 100644 --- a/spec/features/create_exam_paper_spec.rb +++ b/spec/features/create_exam_paper_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/create_journal_article_spec.rb b/spec/features/create_journal_article_spec.rb index 8dbf1cbe..a6e7825a 100644 --- a/spec/features/create_journal_article_spec.rb +++ b/spec/features/create_journal_article_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/create_published_work_spec.rb b/spec/features/create_published_work_spec.rb index a3713474..5f70650b 100644 --- a/spec/features/create_published_work_spec.rb +++ b/spec/features/create_published_work_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/create_thesis_spec.rb b/spec/features/create_thesis_spec.rb index a979a147..9debda07 100644 --- a/spec/features/create_thesis_spec.rb +++ b/spec/features/create_thesis_spec.rb @@ -21,13 +21,12 @@ active: true, name: 'test-workflow', permission_template: - permission_template ) end before do # Create a single action that can be taken - Sipity::WorkflowAction.create!(name: 'submit', workflow: workflow) + Sipity::WorkflowAction.create!(name: 'submit', workflow:) # Grant the user access to deposit into the admin set. Hyrax::PermissionTemplateAccess.create!( diff --git a/spec/features/facet_by_year_spec.rb b/spec/features/facet_by_year_spec.rb index 0bd4e236..67199d2a 100644 --- a/spec/features/facet_by_year_spec.rb +++ b/spec/features/facet_by_year_spec.rb @@ -184,7 +184,7 @@ WebMock.disable! Apartment::Tenant.create(account.tenant) Apartment::Tenant.switch(account.tenant) do - Site.update(account: account) + Site.update(account:) end # sign up user 1 at account 1 diff --git a/spec/helpers/hyku_knapsack/application_helper_spec.rb b/spec/helpers/hyku_knapsack/application_helper_spec.rb index 7f96a470..490c3d61 100644 --- a/spec/helpers/hyku_knapsack/application_helper_spec.rb +++ b/spec/helpers/hyku_knapsack/application_helper_spec.rb @@ -6,7 +6,7 @@ let(:helper) { _view } let(:cname) { 'hyku-me.test' } - let(:account) { build(:search_only_account, cname: cname) } + let(:account) { build(:search_only_account, cname:) } let(:uuid) { SecureRandom.uuid } let(:request) do @@ -14,7 +14,7 @@ port: 3000, protocol: "https://", host: account.cname, - params: { q: q }) + params: { q: }) end let(:doc) { SolrDocument.new(id: uuid, 'has_model_ssim': ['GenericWork'], 'account_cname_tesim': account.cname) } diff --git a/spec/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter_spec.rb b/spec/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter_spec.rb index f948eda4..3ca40d31 100644 --- a/spec/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter_spec.rb +++ b/spec/iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter_spec.rb @@ -4,7 +4,7 @@ RSpec.describe IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter do describe '.split_this?' do - subject { described_class.split_this?(path: path) } + subject { described_class.split_this?(path:) } [ ["hello.jpg", true], diff --git a/spec/jobs/create_derivatives_job_decorator_spec.rb b/spec/jobs/create_derivatives_job_decorator_spec.rb index bc54fa8f..a7fe1abb 100644 --- a/spec/jobs/create_derivatives_job_decorator_spec.rb +++ b/spec/jobs/create_derivatives_job_decorator_spec.rb @@ -8,9 +8,9 @@ end describe '.create_derivative_for?' do - subject { described_class.create_derivative_for?(file_set: file_set) } + subject { described_class.create_derivative_for?(file_set:) } - let(:file_set) { double(FileSet, label: label) } + let(:file_set) { double(FileSet, label:) } context 'when the file set is for a skipped suffix' do let(:label) { "my-non-archival#{described_class::FILE_SUFFIXES_TO_SKIP_DERIVATIVE_CREATION.first}" } diff --git a/spec/jobs/file_sets_reprocess_job_spec.rb b/spec/jobs/file_sets_reprocess_job_spec.rb index 103b9417..67fc3e70 100644 --- a/spec/jobs/file_sets_reprocess_job_spec.rb +++ b/spec/jobs/file_sets_reprocess_job_spec.rb @@ -4,7 +4,7 @@ RSpec.describe FileSetsReprocessJob, clean: true do let(:user) { FactoryBot.create(:user) } - let(:file_set) { FactoryBot.create(:file_with_work_and_file_set, content: file_content, user: user, label: 'latex.pdf') } + let(:file_set) { FactoryBot.create(:file_with_work_and_file_set, content: file_content, user:, label: 'latex.pdf') } let(:file_content) { File.open('spec/fixtures/latex.pdf') } describe '#perform' do @@ -30,7 +30,7 @@ expect(IiifPrint::Jobs::RequestSplitPdfJob) .to receive(:perform_later) - .with(file_set: file_set, user: User.batch_user) + .with(file_set:, user: User.batch_user) FileSetsReprocessJob::ConditionallyResplitFileSetJob.perform_now(file_set_id: file_set.id) end end diff --git a/spec/models/bulkrax/csv_entry_spec.rb b/spec/models/bulkrax/csv_entry_spec.rb index bb4a0cef..e7ebf23a 100644 --- a/spec/models/bulkrax/csv_entry_spec.rb +++ b/spec/models/bulkrax/csv_entry_spec.rb @@ -8,8 +8,8 @@ describe "#build_metadata" do subject(:entry) do Bulkrax::EntrySpecHelper.entry_for( - data: data, - identifier: identifier, + data:, + identifier:, parser_class_name: 'Bulkrax::CsvParser', parser_fields: { 'import_file_path' => "spec/fixtures/csv/entry.csv" } ) diff --git a/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb b/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb index ff5c5a9d..ae706577 100644 --- a/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb +++ b/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb @@ -9,8 +9,8 @@ subject(:entry) do Bulkrax::EntrySpecHelper.entry_for( entry_class: described_class, - identifier: identifier, - data: data, + identifier:, + data:, parser_class_name: "Bulkrax::OaiAdventistQdcParser", parser_fields: { "base_url" => "http://oai.adventistdigitallibrary.org/OAI-script" diff --git a/spec/models/bulkrax/oai_adventist_set_entry_spec.rb b/spec/models/bulkrax/oai_adventist_set_entry_spec.rb index 4948f24e..e08f8bc8 100644 --- a/spec/models/bulkrax/oai_adventist_set_entry_spec.rb +++ b/spec/models/bulkrax/oai_adventist_set_entry_spec.rb @@ -8,8 +8,8 @@ subject(:entry) do Bulkrax::EntrySpecHelper.entry_for( entry_class: described_class, - identifier: identifier, - data: data, + identifier:, + data:, parser_class_name: "Bulkrax::OaiAdventistQdcParser" ) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index e334da24..1c7b41ae 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -35,7 +35,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = Rails.root.join('spec', 'fixtures', 'fixtures').to_s # They enable url_helpers not to throw error in Rspec system spec and request spec. # config.include Rails.application.routes.url_helpers From 54adf772b06eba6764477c48ec9f036155681a8c Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Thu, 15 Aug 2024 17:25:41 -0700 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=92=84=20Fixing=20linting=20for=20Adv?= =?UTF-8?q?entist=20Valkyrie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the linting issues on the Adventist Valkyrie project. The files in this commit contain only whitespace changes or changing Note comments to NOTE as suggested by Rubocop. There should not be any changes to the functionality of the application. Ref: - https://github.com/scientist-softserv/adventist_knapsack/issues/741 --- .../hyrax/conference_items_controller.rb | 2 +- .../hyrax/file_set_indexer_decorator.rb | 20 +-- app/jobs/application_job_decorator.rb | 1 - app/models/bulkrax/oai_adventist_qdc_entry.rb | 2 +- app/models/bulkrax/oai_adventist_set_entry.rb | 2 +- app/models/generic_work_decorator.rb | 2 +- app/models/image_decorator.rb | 2 +- .../bulkrax/adventist_csv_parser_decorator.rb | 48 +++--- ...if_manifest_presenter_factory_decorator.rb | 2 +- .../hyku/work_show_presenter_decorator.rb | 7 +- app/renderers/publication_status_renderer.rb | 16 +- .../wings/custom_queries/find_by_slug.rb | 4 +- .../hyrax/uploaded_file_uploader_decorator.rb | 4 +- bundler.d/example.rb | 5 +- ...5211201_create_version_committers.hyrax.rb | 15 ++ ...211202_create_checksum_audit_logs.hyrax.rb | 19 ++ ...815211203_create_single_use_links.hyrax.rb | 12 ++ ...0240815211204_add_social_to_users.hyrax.rb | 13 ++ ...0815211205_add_ldap_attrs_to_user.hyrax.rb | 27 +++ ...240815211206_add_avatars_to_users.hyrax.rb | 15 ++ .../20240815211207_create_trophies.hyrax.rb | 10 ++ ...40815211208_add_linkedin_to_users.hyrax.rb | 5 + ...40815211209_create_tinymce_assets.hyrax.rb | 8 + ...40815211210_create_content_blocks.hyrax.rb | 10 ++ ...40815211211_create_featured_works.hyrax.rb | 12 ++ ...dd_external_key_to_content_blocks.hyrax.rb | 6 + ...11213_create_proxy_deposit_rights.hyrax.rb | 10 ++ ...214_create_proxy_deposit_requests.hyrax.rb | 15 ++ ...0815211215_create_file_view_stats.hyrax.rb | 12 ++ ...211216_create_file_download_stats.hyrax.rb | 12 ++ ...20240815211217_add_orcid_to_users.hyrax.rb | 5 + .../20240815211218_create_user_stats.hyrax.rb | 19 ++ ...0815211219_create_work_view_stats.hyrax.rb | 12 ++ ...815211220_add_works_to_user_stats.hyrax.rb | 13 ++ ...trophy_generic_file_id_to_work_id.hyrax.rb | 5 + ...eposit_generic_file_id_to_work_id.hyrax.rb | 5 + ...og_generic_file_id_to_file_set_id.hyrax.rb | 5 + ...equest_generic_file_id_to_work_id.hyrax.rb | 5 + ...40815211225_create_uploaded_files.hyrax.rb | 10 ++ .../20240815211226_create_features.hyrax.rb | 10 ++ .../20240815211227_create_operations.hyrax.rb | 23 +++ ...d_work_generic_file_id_to_work_id.hyrax.rb | 6 + ...0240815211229_add_arkivo_to_users.hyrax.rb | 8 + .../20240815211230_create_sipity.hyrax.rb | 163 ++++++++++++++++++ ...31_create_sipity_workflow_methods.hyrax.rb | 10 ++ ...211232_create_permission_template.hyrax.rb | 11 ++ ...create_permission_template_access.hyrax.rb | 11 ++ ...d_release_to_permission_templates.hyrax.rb | 6 + ...ssion_template_to_sipity_workflow.hyrax.rb | 26 +++ ..._tidy_up_because_of_bad_exception.hyrax.rb | 13 ++ ...d_allows_access_grant_to_workflow.hyrax.rb | 5 + ...5211238_change_checksum_audit_log.hyrax.rb | 18 ++ ...0815211239_create_job_io_wrappers.hyrax.rb | 15 ++ ...815211240_create_collection_types.hyrax.rb | 17 ++ ...date_collection_type_column_names.hyrax.rb | 9 + ...te_collection_type_column_options.hyrax.rb | 17 ++ ..._create_collection_branding_infos.hyrax.rb | 15 ++ ...eate_collection_type_participants.hyrax.rb | 11 ++ ..._rename_admin_set_id_to_source_id.hyrax.rb | 5 + ...246_add_preferred_locale_to_users.hyrax.rb | 5 + ...d_collection_type_sharing_options.hyrax.rb | 5 + ...t_to_permission_template_accesses.hyrax.rb | 8 + ...9_add_branding_to_collection_type.hyrax.rb | 5 + ...d_badge_color_to_collection_types.hyrax.rb | 5 + ...ate_single_use_links_column_names.hyrax.rb | 6 + ...ty_entity_specific_responsibility.hyrax.rb | 9 + ...create_default_administrative_set.hyrax.rb | 8 + ...1254_create_hyrax_counter_metrics.hyrax.rb | 14 ++ ...15211255_change_work_id_to_string.hyrax.rb | 5 + ..._indices_to_hyrax_counter_metrics.hyrax.rb | 8 + ...1257_add_fields_to_counter_metric.hyrax.rb | 8 + lib/active_job_tenant.rb | 22 +-- lib/dog_biscuits/actors/apply_authorities.rb | 38 ++-- .../property_mappings/property_mappings.rb | 4 +- .../forms/collection_form_decorator_spec.rb | 2 +- .../text_file_text_extraction_service_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 77 files changed, 858 insertions(+), 94 deletions(-) create mode 100644 db/migrate/20240815211201_create_version_committers.hyrax.rb create mode 100644 db/migrate/20240815211202_create_checksum_audit_logs.hyrax.rb create mode 100644 db/migrate/20240815211203_create_single_use_links.hyrax.rb create mode 100644 db/migrate/20240815211204_add_social_to_users.hyrax.rb create mode 100644 db/migrate/20240815211205_add_ldap_attrs_to_user.hyrax.rb create mode 100644 db/migrate/20240815211206_add_avatars_to_users.hyrax.rb create mode 100644 db/migrate/20240815211207_create_trophies.hyrax.rb create mode 100644 db/migrate/20240815211208_add_linkedin_to_users.hyrax.rb create mode 100644 db/migrate/20240815211209_create_tinymce_assets.hyrax.rb create mode 100644 db/migrate/20240815211210_create_content_blocks.hyrax.rb create mode 100644 db/migrate/20240815211211_create_featured_works.hyrax.rb create mode 100644 db/migrate/20240815211212_add_external_key_to_content_blocks.hyrax.rb create mode 100644 db/migrate/20240815211213_create_proxy_deposit_rights.hyrax.rb create mode 100644 db/migrate/20240815211214_create_proxy_deposit_requests.hyrax.rb create mode 100644 db/migrate/20240815211215_create_file_view_stats.hyrax.rb create mode 100644 db/migrate/20240815211216_create_file_download_stats.hyrax.rb create mode 100644 db/migrate/20240815211217_add_orcid_to_users.hyrax.rb create mode 100644 db/migrate/20240815211218_create_user_stats.hyrax.rb create mode 100644 db/migrate/20240815211219_create_work_view_stats.hyrax.rb create mode 100644 db/migrate/20240815211220_add_works_to_user_stats.hyrax.rb create mode 100644 db/migrate/20240815211221_change_trophy_generic_file_id_to_work_id.hyrax.rb create mode 100644 db/migrate/20240815211222_change_proxy_deposit_generic_file_id_to_work_id.hyrax.rb create mode 100644 db/migrate/20240815211223_change_audit_log_generic_file_id_to_file_set_id.hyrax.rb create mode 100644 db/migrate/20240815211224_change_proxy_deposit_request_generic_file_id_to_work_id.hyrax.rb create mode 100644 db/migrate/20240815211225_create_uploaded_files.hyrax.rb create mode 100644 db/migrate/20240815211226_create_features.hyrax.rb create mode 100644 db/migrate/20240815211227_create_operations.hyrax.rb create mode 100644 db/migrate/20240815211228_change_featured_work_generic_file_id_to_work_id.hyrax.rb create mode 100644 db/migrate/20240815211229_add_arkivo_to_users.hyrax.rb create mode 100644 db/migrate/20240815211230_create_sipity.hyrax.rb create mode 100644 db/migrate/20240815211231_create_sipity_workflow_methods.hyrax.rb create mode 100644 db/migrate/20240815211232_create_permission_template.hyrax.rb create mode 100644 db/migrate/20240815211233_create_permission_template_access.hyrax.rb create mode 100644 db/migrate/20240815211234_add_release_to_permission_templates.hyrax.rb create mode 100644 db/migrate/20240815211235_add_permission_template_to_sipity_workflow.hyrax.rb create mode 100644 db/migrate/20240815211236_tidy_up_because_of_bad_exception.hyrax.rb create mode 100644 db/migrate/20240815211237_add_allows_access_grant_to_workflow.hyrax.rb create mode 100644 db/migrate/20240815211238_change_checksum_audit_log.hyrax.rb create mode 100644 db/migrate/20240815211239_create_job_io_wrappers.hyrax.rb create mode 100644 db/migrate/20240815211240_create_collection_types.hyrax.rb create mode 100644 db/migrate/20240815211241_update_collection_type_column_names.hyrax.rb create mode 100644 db/migrate/20240815211242_update_collection_type_column_options.hyrax.rb create mode 100644 db/migrate/20240815211243_create_collection_branding_infos.hyrax.rb create mode 100644 db/migrate/20240815211244_create_collection_type_participants.hyrax.rb create mode 100644 db/migrate/20240815211245_rename_admin_set_id_to_source_id.hyrax.rb create mode 100644 db/migrate/20240815211246_add_preferred_locale_to_users.hyrax.rb create mode 100644 db/migrate/20240815211247_add_collection_type_sharing_options.hyrax.rb create mode 100644 db/migrate/20240815211248_add_unique_constraint_to_permission_template_accesses.hyrax.rb create mode 100644 db/migrate/20240815211249_add_branding_to_collection_type.hyrax.rb create mode 100644 db/migrate/20240815211250_add_badge_color_to_collection_types.hyrax.rb create mode 100644 db/migrate/20240815211251_update_single_use_links_column_names.hyrax.rb create mode 100644 db/migrate/20240815211252_change_sipity_entity_specific_responsibility.hyrax.rb create mode 100644 db/migrate/20240815211253_create_default_administrative_set.hyrax.rb create mode 100644 db/migrate/20240815211254_create_hyrax_counter_metrics.hyrax.rb create mode 100644 db/migrate/20240815211255_change_work_id_to_string.hyrax.rb create mode 100644 db/migrate/20240815211256_add_indices_to_hyrax_counter_metrics.hyrax.rb create mode 100644 db/migrate/20240815211257_add_fields_to_counter_metric.hyrax.rb diff --git a/app/controllers/hyrax/conference_items_controller.rb b/app/controllers/hyrax/conference_items_controller.rb index 3fbdfacf..eeb7ddc4 100644 --- a/app/controllers/hyrax/conference_items_controller.rb +++ b/app/controllers/hyrax/conference_items_controller.rb @@ -14,7 +14,7 @@ class ConferenceItemsController < ApplicationController # Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style # forms. self.work_form_service = Hyrax::FormFactory.new - + # Use this line if you want to use a custom presenter self.show_presenter = Hyrax::ConferenceItemPresenter end diff --git a/app/indexers/hyrax/file_set_indexer_decorator.rb b/app/indexers/hyrax/file_set_indexer_decorator.rb index a241cb70..ecd94f39 100644 --- a/app/indexers/hyrax/file_set_indexer_decorator.rb +++ b/app/indexers/hyrax/file_set_indexer_decorator.rb @@ -16,17 +16,17 @@ def generate_solr_document private - def pdf_text - text = IO.popen(['pdftotext', '-', '-'], 'r+b') do |pdftotext| - pdftotext.write(object.original_file.content) - pdftotext.close_write - pdftotext.read - end - - text.tr("\n", ' ') - .squeeze(' ') - .encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') # remove non-UTF-8 characters + def pdf_text + text = IO.popen(['pdftotext', '-', '-'], 'r+b') do |pdftotext| + pdftotext.write(object.original_file.content) + pdftotext.close_write + pdftotext.read end + + text.tr("\n", ' ') + .squeeze(' ') + .encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') # remove non-UTF-8 characters + end end end diff --git a/app/jobs/application_job_decorator.rb b/app/jobs/application_job_decorator.rb index dc1610bc..867db662 100644 --- a/app/jobs/application_job_decorator.rb +++ b/app/jobs/application_job_decorator.rb @@ -45,7 +45,6 @@ module ApplicationJobDecorator end end - def redirect_priority_jobs return :ingest unless priority_tenants_array.include? tenant_name PRIORITY_QUEUE_NAME diff --git a/app/models/bulkrax/oai_adventist_qdc_entry.rb b/app/models/bulkrax/oai_adventist_qdc_entry.rb index 307c5969..654a89e1 100644 --- a/app/models/bulkrax/oai_adventist_qdc_entry.rb +++ b/app/models/bulkrax/oai_adventist_qdc_entry.rb @@ -12,7 +12,7 @@ def field_to(field) super(field) end - # Note: We're overriding the setting of the thumbnail_url as per prior implementations in + # NOTE: We're overriding the setting of the thumbnail_url as per prior implementations in # Adventist's code-base. def add_thumbnail_url true diff --git a/app/models/bulkrax/oai_adventist_set_entry.rb b/app/models/bulkrax/oai_adventist_set_entry.rb index e6f51943..6caeae57 100644 --- a/app/models/bulkrax/oai_adventist_set_entry.rb +++ b/app/models/bulkrax/oai_adventist_set_entry.rb @@ -18,7 +18,7 @@ def build_metadata end end - # Note: as of the time of writing this comment, the Bulkrax::OaiSetEntry does not handle + # NOTE: as of the time of writing this comment, the Bulkrax::OaiSetEntry does not handle # metadata nor does it do anything with visibility, rights statements, or admin sets. This is # added as an override that I'd love to see "removed" add_visibility diff --git a/app/models/generic_work_decorator.rb b/app/models/generic_work_decorator.rb index eccf5bce..d097711f 100644 --- a/app/models/generic_work_decorator.rb +++ b/app/models/generic_work_decorator.rb @@ -15,7 +15,7 @@ derivative_service_plugins: [ IiifPrint::TextExtractionDerivativeService ] -)) + )) # This must come after the properties because it finalizes the metadata # schema (by adding accepts_nested_attributes) diff --git a/app/models/image_decorator.rb b/app/models/image_decorator.rb index 614c997a..8e97c4e2 100644 --- a/app/models/image_decorator.rb +++ b/app/models/image_decorator.rb @@ -15,7 +15,7 @@ derivative_service_plugins: [ IiifPrint::TextExtractionDerivativeService ] -)) + )) # This must come after the properties because it finalizes the metadata # schema (by adding accepts_nested_attributes) diff --git a/app/parsers/bulkrax/adventist_csv_parser_decorator.rb b/app/parsers/bulkrax/adventist_csv_parser_decorator.rb index 71d662f3..73b6c37f 100644 --- a/app/parsers/bulkrax/adventist_csv_parser_decorator.rb +++ b/app/parsers/bulkrax/adventist_csv_parser_decorator.rb @@ -14,35 +14,35 @@ def missing_elements(record) private - def extract_keys_from_record(record) - keys = record.reject { |_, v| v.blank? } - .keys - .compact - .uniq - .map(&:to_s) - .map(&:strip) - .map { |k| Bulkrax.normalize_string(k) } - keys_without_numbers(keys) - end + def extract_keys_from_record(record) + keys = record.reject { |_, v| v.blank? } + .keys + .compact + .uniq + .map(&:to_s) + .map(&:strip) + .map { |k| Bulkrax.normalize_string(k) } + keys_without_numbers(keys) + end - def collect_keys_from_mapping(keys_from_record) - keys = [] - importerexporter.mapping.stringify_keys.each do |k, v| - Array.wrap(v['from']).each do |vf| - vf_str = Bulkrax.normalize_string(vf.to_s.strip) - keys << k.to_s.strip if keys_from_record.include?(vf_str) - end + def collect_keys_from_mapping(keys_from_record) + keys = [] + importerexporter.mapping.stringify_keys.each do |k, v| + Array.wrap(v['from']).each do |vf| + vf_str = Bulkrax.normalize_string(vf.to_s.strip) + keys << k.to_s.strip if keys_from_record.include?(vf_str) end - keys.uniq.map(&:to_s).map(&:strip).map { |k| Bulkrax.normalize_string(k) } end + keys.uniq.map(&:to_s).map(&:strip).map { |k| Bulkrax.normalize_string(k) } + end - def normalize_elements(elements) - elements.map(&:to_s).map(&:strip).map { |k| Bulkrax.normalize_string(k) } - end + def normalize_elements(elements) + elements.map(&:to_s).map(&:strip).map { |k| Bulkrax.normalize_string(k) } + end - def identify_missing_elements(required_elements, keys) - required_elements - keys - end + def identify_missing_elements(required_elements, keys) + required_elements - keys + end end end diff --git a/app/presenters/adl/iiif_manifest_presenter_factory_decorator.rb b/app/presenters/adl/iiif_manifest_presenter_factory_decorator.rb index b4b3f457..5afadf4e 100644 --- a/app/presenters/adl/iiif_manifest_presenter_factory_decorator.rb +++ b/app/presenters/adl/iiif_manifest_presenter_factory_decorator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# OVERRIDE IiifPrint v3.0.1 to check has_model instead of hydra_model. +# OVERRIDE IiifPrint v3.0.1 to check has_model instead of hydra_model. # Hyrax.config.curation_concerns does not include "Resource" module Adl diff --git a/app/presenters/hyku/work_show_presenter_decorator.rb b/app/presenters/hyku/work_show_presenter_decorator.rb index 55482817..921d1c72 100644 --- a/app/presenters/hyku/work_show_presenter_decorator.rb +++ b/app/presenters/hyku/work_show_presenter_decorator.rb @@ -31,11 +31,12 @@ def pdf_extension? def viewer? iiif_viewer? || video_embed_viewer? || pdf_viewer? end + private - def model_klass - model_name.instance_variable_get(:@klass) - end + def model_klass + model_name.instance_variable_get(:@klass) + end end end diff --git a/app/renderers/publication_status_renderer.rb b/app/renderers/publication_status_renderer.rb index 6b857bfd..01b7c9ed 100644 --- a/app/renderers/publication_status_renderer.rb +++ b/app/renderers/publication_status_renderer.rb @@ -5,13 +5,13 @@ class PublicationStatusRenderer < Hyrax::Renderers::AttributeRenderer private - def li_value(value) - link_to(ERB::Util.h(publication_status_label(value)), search_path(value)) - end + def li_value(value) + link_to(ERB::Util.h(publication_status_label(value)), search_path(value)) + end - def search_path(value) - Rails.application.routes.url_helpers.search_catalog_path( - 'f([publication_status_sim[]])': ERB::Util.h(value), locale: I18n.locale - ) - end + def search_path(value) + Rails.application.routes.url_helpers.search_catalog_path( + 'f([publication_status_sim[]])': ERB::Util.h(value), locale: I18n.locale + ) + end end diff --git a/app/services/wings/custom_queries/find_by_slug.rb b/app/services/wings/custom_queries/find_by_slug.rb index af0d2e88..310adb24 100644 --- a/app/services/wings/custom_queries/find_by_slug.rb +++ b/app/services/wings/custom_queries/find_by_slug.rb @@ -6,11 +6,11 @@ class FindBySlug def self.queries [:find_by_slug] end - + def initialize(query_service:) @query_service = query_service end - + attr_reader :query_service delegate :resource_factory, to: :query_service diff --git a/app/uploaders/hyrax/uploaded_file_uploader_decorator.rb b/app/uploaders/hyrax/uploaded_file_uploader_decorator.rb index 16bc2da7..51c96f28 100644 --- a/app/uploaders/hyrax/uploaded_file_uploader_decorator.rb +++ b/app/uploaders/hyrax/uploaded_file_uploader_decorator.rb @@ -7,9 +7,9 @@ def filename end def original_file_name - model.filename + model.filename end end end -Hyrax::UploadedFileUploader.prepend(Hyrax::UploadedFileUploaderDecorator) \ No newline at end of file +Hyrax::UploadedFileUploader.prepend(Hyrax::UploadedFileUploaderDecorator) diff --git a/bundler.d/example.rb b/bundler.d/example.rb index 7f98c30c..0143112b 100644 --- a/bundler.d/example.rb +++ b/bundler.d/example.rb @@ -6,8 +6,7 @@ # or `ensure_gem` to make sure a gem is there w/o worrying about if it is an # override or not -# Note: these injected gems are very sticky... it appears that you must rebuild -# your docker container and rebundle to get rid of an injected gem. +# NOTE: these injected gems are very sticky... it appears that you must rebuild +# your docker container and rebundle to get rid of an injected gem. ensure_gem 'derivative-rodeo', '~> 0.5', '>= 0.5.3' - diff --git a/db/migrate/20240815211201_create_version_committers.hyrax.rb b/db/migrate/20240815211201_create_version_committers.hyrax.rb new file mode 100644 index 00000000..073d97fc --- /dev/null +++ b/db/migrate/20240815211201_create_version_committers.hyrax.rb @@ -0,0 +1,15 @@ +class CreateVersionCommitters < ActiveRecord::Migration[6.1] + def self.up + create_table :version_committers do |t| + t.string :obj_id + t.string :datastream_id + t.string :version_id + t.string :committer_login + t.timestamps null: false + end + end + + def self.down + drop_table :version_committers + end +end diff --git a/db/migrate/20240815211202_create_checksum_audit_logs.hyrax.rb b/db/migrate/20240815211202_create_checksum_audit_logs.hyrax.rb new file mode 100644 index 00000000..a88052c8 --- /dev/null +++ b/db/migrate/20240815211202_create_checksum_audit_logs.hyrax.rb @@ -0,0 +1,19 @@ +class CreateChecksumAuditLogs < ActiveRecord::Migration[6.1] + def self.up + create_table :checksum_audit_logs do |t| + t.string :file_set_id + t.string :file_id + t.string :version + t.integer :pass + t.string :expected_result + t.string :actual_result + t.timestamps null: false + end + add_index :checksum_audit_logs, [:file_set_id, :file_id], name: 'by_file_set_id_and_file_id', order: { created_at: 'DESC' } + end + + def self.down + remove_index(:checksum_audit_logs, name: 'by_file_set_id_and_file_id') + drop_table :checksum_audit_logs + end +end diff --git a/db/migrate/20240815211203_create_single_use_links.hyrax.rb b/db/migrate/20240815211203_create_single_use_links.hyrax.rb new file mode 100644 index 00000000..64a03b31 --- /dev/null +++ b/db/migrate/20240815211203_create_single_use_links.hyrax.rb @@ -0,0 +1,12 @@ +class CreateSingleUseLinks < ActiveRecord::Migration[6.1] + def change + create_table :single_use_links do |t| + t.string :downloadKey + t.string :path + t.string :itemId + t.datetime :expires + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211204_add_social_to_users.hyrax.rb b/db/migrate/20240815211204_add_social_to_users.hyrax.rb new file mode 100644 index 00000000..328603ec --- /dev/null +++ b/db/migrate/20240815211204_add_social_to_users.hyrax.rb @@ -0,0 +1,13 @@ +class AddSocialToUsers < ActiveRecord::Migration[6.1] + def self.up + add_column :users, :facebook_handle, :string + add_column :users, :twitter_handle, :string + add_column :users, :googleplus_handle, :string + end + + def self.down + remove_column :users, :facebook_handle, :string + remove_column :users, :twitter_handle, :string + remove_column :users, :googleplus_handle, :string + end +end diff --git a/db/migrate/20240815211205_add_ldap_attrs_to_user.hyrax.rb b/db/migrate/20240815211205_add_ldap_attrs_to_user.hyrax.rb new file mode 100644 index 00000000..6435adf2 --- /dev/null +++ b/db/migrate/20240815211205_add_ldap_attrs_to_user.hyrax.rb @@ -0,0 +1,27 @@ +class AddLdapAttrsToUser < ActiveRecord::Migration[6.1] + def self.up + add_column :users, :display_name, :string + add_column :users, :address, :string + add_column :users, :admin_area, :string + add_column :users, :department, :string + add_column :users, :title, :string + add_column :users, :office, :string + add_column :users, :chat_id, :string + add_column :users, :website, :string + add_column :users, :affiliation, :string + add_column :users, :telephone, :string + end + + def self.down + remove_column :users, :display_name + remove_column :users, :address + remove_column :users, :admin_area + remove_column :users, :department + remove_column :users, :title + remove_column :users, :office + remove_column :users, :chat_id + remove_column :users, :website + remove_column :users, :affiliation + remove_column :users, :telephone + end +end diff --git a/db/migrate/20240815211206_add_avatars_to_users.hyrax.rb b/db/migrate/20240815211206_add_avatars_to_users.hyrax.rb new file mode 100644 index 00000000..44da5bd9 --- /dev/null +++ b/db/migrate/20240815211206_add_avatars_to_users.hyrax.rb @@ -0,0 +1,15 @@ +class AddAvatarsToUsers < ActiveRecord::Migration[6.1] + def self.up + add_column :users, "avatar_file_name", :string + add_column :users, "avatar_content_type", :string + add_column :users, "avatar_file_size", :integer + add_column :users, "avatar_updated_at", :datetime + end + + def self.down + remove_column :users, "avatar_file_name" + remove_column :users, "avatar_content_type" + remove_column :users, "avatar_file_size" + remove_column :users, "avatar_updated_at" + end +end diff --git a/db/migrate/20240815211207_create_trophies.hyrax.rb b/db/migrate/20240815211207_create_trophies.hyrax.rb new file mode 100644 index 00000000..6056dd7c --- /dev/null +++ b/db/migrate/20240815211207_create_trophies.hyrax.rb @@ -0,0 +1,10 @@ +class CreateTrophies < ActiveRecord::Migration[6.1] + def change + create_table :trophies do |t| + t.integer :user_id + t.string :generic_file_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211208_add_linkedin_to_users.hyrax.rb b/db/migrate/20240815211208_add_linkedin_to_users.hyrax.rb new file mode 100644 index 00000000..80128c04 --- /dev/null +++ b/db/migrate/20240815211208_add_linkedin_to_users.hyrax.rb @@ -0,0 +1,5 @@ +class AddLinkedinToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :linkedin_handle, :string + end +end diff --git a/db/migrate/20240815211209_create_tinymce_assets.hyrax.rb b/db/migrate/20240815211209_create_tinymce_assets.hyrax.rb new file mode 100644 index 00000000..790d6a3d --- /dev/null +++ b/db/migrate/20240815211209_create_tinymce_assets.hyrax.rb @@ -0,0 +1,8 @@ +class CreateTinymceAssets < ActiveRecord::Migration[6.1] + def change + create_table :tinymce_assets do |t| + t.string :file + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211210_create_content_blocks.hyrax.rb b/db/migrate/20240815211210_create_content_blocks.hyrax.rb new file mode 100644 index 00000000..b051411f --- /dev/null +++ b/db/migrate/20240815211210_create_content_blocks.hyrax.rb @@ -0,0 +1,10 @@ +class CreateContentBlocks < ActiveRecord::Migration[6.1] + def change + create_table :content_blocks do |t| + t.string :name + t.text :value + t.timestamps null: false + end + add_index :content_blocks, :name, unique: true + end +end diff --git a/db/migrate/20240815211211_create_featured_works.hyrax.rb b/db/migrate/20240815211211_create_featured_works.hyrax.rb new file mode 100644 index 00000000..b4c49f27 --- /dev/null +++ b/db/migrate/20240815211211_create_featured_works.hyrax.rb @@ -0,0 +1,12 @@ +class CreateFeaturedWorks < ActiveRecord::Migration[6.1] + def change + create_table :featured_works do |t| + t.integer :order, default: 5 + t.string :work_id + + t.timestamps null: false + end + add_index :featured_works, :work_id + add_index :featured_works, :order + end +end diff --git a/db/migrate/20240815211212_add_external_key_to_content_blocks.hyrax.rb b/db/migrate/20240815211212_add_external_key_to_content_blocks.hyrax.rb new file mode 100644 index 00000000..4a2eca6e --- /dev/null +++ b/db/migrate/20240815211212_add_external_key_to_content_blocks.hyrax.rb @@ -0,0 +1,6 @@ +class AddExternalKeyToContentBlocks < ActiveRecord::Migration[6.1] + def change + add_column :content_blocks, :external_key, :string + remove_index :content_blocks, :name + end +end diff --git a/db/migrate/20240815211213_create_proxy_deposit_rights.hyrax.rb b/db/migrate/20240815211213_create_proxy_deposit_rights.hyrax.rb new file mode 100644 index 00000000..77075a65 --- /dev/null +++ b/db/migrate/20240815211213_create_proxy_deposit_rights.hyrax.rb @@ -0,0 +1,10 @@ +class CreateProxyDepositRights < ActiveRecord::Migration[6.1] + def change + create_table :proxy_deposit_rights do |t| + t.references :grantor + t.references :grantee + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20240815211214_create_proxy_deposit_requests.hyrax.rb b/db/migrate/20240815211214_create_proxy_deposit_requests.hyrax.rb new file mode 100644 index 00000000..670d42dc --- /dev/null +++ b/db/migrate/20240815211214_create_proxy_deposit_requests.hyrax.rb @@ -0,0 +1,15 @@ +class CreateProxyDepositRequests < ActiveRecord::Migration[6.1] + def change + create_table :proxy_deposit_requests do |t| + t.string :generic_file_id, null: false + t.references :sending_user, null: false + t.references :receiving_user, null: false + t.datetime :fulfillment_date + t.string :status, null: false, default: 'pending' + t.text :sender_comment + t.text :receiver_comment + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20240815211215_create_file_view_stats.hyrax.rb b/db/migrate/20240815211215_create_file_view_stats.hyrax.rb new file mode 100644 index 00000000..7e5300db --- /dev/null +++ b/db/migrate/20240815211215_create_file_view_stats.hyrax.rb @@ -0,0 +1,12 @@ +class CreateFileViewStats < ActiveRecord::Migration[6.1] + def change + create_table :file_view_stats do |t| + t.datetime :date + t.integer :views + t.string :file_id + + t.timestamps null: false + end + add_index :file_view_stats, :file_id + end +end diff --git a/db/migrate/20240815211216_create_file_download_stats.hyrax.rb b/db/migrate/20240815211216_create_file_download_stats.hyrax.rb new file mode 100644 index 00000000..89710bd4 --- /dev/null +++ b/db/migrate/20240815211216_create_file_download_stats.hyrax.rb @@ -0,0 +1,12 @@ +class CreateFileDownloadStats < ActiveRecord::Migration[6.1] + def change + create_table :file_download_stats do |t| + t.datetime :date + t.integer :downloads + t.string :file_id + + t.timestamps null: false + end + add_index :file_download_stats, :file_id + end +end diff --git a/db/migrate/20240815211217_add_orcid_to_users.hyrax.rb b/db/migrate/20240815211217_add_orcid_to_users.hyrax.rb new file mode 100644 index 00000000..661aa120 --- /dev/null +++ b/db/migrate/20240815211217_add_orcid_to_users.hyrax.rb @@ -0,0 +1,5 @@ +class AddOrcidToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :orcid, :string + end +end diff --git a/db/migrate/20240815211218_create_user_stats.hyrax.rb b/db/migrate/20240815211218_create_user_stats.hyrax.rb new file mode 100644 index 00000000..cea7b9ac --- /dev/null +++ b/db/migrate/20240815211218_create_user_stats.hyrax.rb @@ -0,0 +1,19 @@ +class CreateUserStats < ActiveRecord::Migration[6.1] + def change + create_table :user_stats do |t| + t.integer :user_id + t.datetime :date + t.integer :file_views + t.integer :file_downloads + + t.timestamps null: false + end + + add_column :file_view_stats, :user_id, :integer + add_column :file_download_stats, :user_id, :integer + + add_index :user_stats, :user_id + add_index :file_view_stats, :user_id + add_index :file_download_stats, :user_id + end +end diff --git a/db/migrate/20240815211219_create_work_view_stats.hyrax.rb b/db/migrate/20240815211219_create_work_view_stats.hyrax.rb new file mode 100644 index 00000000..aeb79811 --- /dev/null +++ b/db/migrate/20240815211219_create_work_view_stats.hyrax.rb @@ -0,0 +1,12 @@ +class CreateWorkViewStats < ActiveRecord::Migration[6.1] + def change + create_table :work_view_stats do |t| + t.datetime :date + t.integer :work_views + t.string :work_id + + t.timestamps null: false + end + add_index :work_view_stats, :work_id + end +end diff --git a/db/migrate/20240815211220_add_works_to_user_stats.hyrax.rb b/db/migrate/20240815211220_add_works_to_user_stats.hyrax.rb new file mode 100644 index 00000000..b75793f8 --- /dev/null +++ b/db/migrate/20240815211220_add_works_to_user_stats.hyrax.rb @@ -0,0 +1,13 @@ +class AddWorksToUserStats < ActiveRecord::Migration[6.1] + def self.up + add_column :user_stats, :work_views, :integer + add_column :work_view_stats, :user_id, :integer + add_index :work_view_stats, :user_id + end + + def self.down + remove_column :user_stats, :work_views, :integer + remove_column :work_view_stats, :user_id, :integer + remove_index :work_view_stats, :user_id + end +end diff --git a/db/migrate/20240815211221_change_trophy_generic_file_id_to_work_id.hyrax.rb b/db/migrate/20240815211221_change_trophy_generic_file_id_to_work_id.hyrax.rb new file mode 100644 index 00000000..4263359f --- /dev/null +++ b/db/migrate/20240815211221_change_trophy_generic_file_id_to_work_id.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeTrophyGenericFileIdToWorkId < ActiveRecord::Migration[6.1] + def change + rename_column :trophies, :generic_file_id, :work_id + end +end diff --git a/db/migrate/20240815211222_change_proxy_deposit_generic_file_id_to_work_id.hyrax.rb b/db/migrate/20240815211222_change_proxy_deposit_generic_file_id_to_work_id.hyrax.rb new file mode 100644 index 00000000..4d73d07a --- /dev/null +++ b/db/migrate/20240815211222_change_proxy_deposit_generic_file_id_to_work_id.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeProxyDepositGenericFileIdToWorkId < ActiveRecord::Migration[6.1] + def change + rename_column :proxy_deposit_requests, :generic_file_id, :work_id + end +end diff --git a/db/migrate/20240815211223_change_audit_log_generic_file_id_to_file_set_id.hyrax.rb b/db/migrate/20240815211223_change_audit_log_generic_file_id_to_file_set_id.hyrax.rb new file mode 100644 index 00000000..bd5b6dd7 --- /dev/null +++ b/db/migrate/20240815211223_change_audit_log_generic_file_id_to_file_set_id.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeAuditLogGenericFileIdToFileSetId < ActiveRecord::Migration[6.1] + def change + rename_column :checksum_audit_logs, :generic_file_id, :file_set_id unless ChecksumAuditLog.column_names.include?('file_set_id') + end +end diff --git a/db/migrate/20240815211224_change_proxy_deposit_request_generic_file_id_to_work_id.hyrax.rb b/db/migrate/20240815211224_change_proxy_deposit_request_generic_file_id_to_work_id.hyrax.rb new file mode 100644 index 00000000..c4814171 --- /dev/null +++ b/db/migrate/20240815211224_change_proxy_deposit_request_generic_file_id_to_work_id.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeProxyDepositRequestGenericFileIdToWorkId < ActiveRecord::Migration[6.1] + def change + rename_column :proxy_deposit_requests, :generic_file_id, :generic_id if ProxyDepositRequest.column_names.include?('generic_file_id') + end +end diff --git a/db/migrate/20240815211225_create_uploaded_files.hyrax.rb b/db/migrate/20240815211225_create_uploaded_files.hyrax.rb new file mode 100644 index 00000000..2d93ccaf --- /dev/null +++ b/db/migrate/20240815211225_create_uploaded_files.hyrax.rb @@ -0,0 +1,10 @@ +class CreateUploadedFiles < ActiveRecord::Migration[6.1] + def change + create_table :uploaded_files do |t| + t.string :file + t.references :user, index: true, foreign_key: true + t.string :file_set_uri, index: true + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211226_create_features.hyrax.rb b/db/migrate/20240815211226_create_features.hyrax.rb new file mode 100644 index 00000000..66971ceb --- /dev/null +++ b/db/migrate/20240815211226_create_features.hyrax.rb @@ -0,0 +1,10 @@ +class CreateFeatures < ActiveRecord::Migration[6.1] + def change + create_table :hyrax_features do |t| + t.string :key, null: false + t.boolean :enabled, null: false, default: false + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211227_create_operations.hyrax.rb b/db/migrate/20240815211227_create_operations.hyrax.rb new file mode 100644 index 00000000..b6d139b2 --- /dev/null +++ b/db/migrate/20240815211227_create_operations.hyrax.rb @@ -0,0 +1,23 @@ +class CreateOperations < ActiveRecord::Migration[6.1] + def change + create_table :curation_concerns_operations do |t| + t.string :status + t.string :operation_type + t.string :job_class + t.string :job_id + t.string :type # For Single Table Inheritance + t.text :message + t.references :user, index: true, foreign_key: true + + t.integer :parent_id, null: true, index: true + t.integer :lft, null: false, index: true + t.integer :rgt, null: false, index: true + + # optional fields + t.integer :depth, null: false, default: 0 + t.integer :children_count, null: false, default: 0 + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211228_change_featured_work_generic_file_id_to_work_id.hyrax.rb b/db/migrate/20240815211228_change_featured_work_generic_file_id_to_work_id.hyrax.rb new file mode 100644 index 00000000..99ddd233 --- /dev/null +++ b/db/migrate/20240815211228_change_featured_work_generic_file_id_to_work_id.hyrax.rb @@ -0,0 +1,6 @@ +class ChangeFeaturedWorkGenericFileIdToWorkId < ActiveRecord::Migration[6.1] + def change + return unless column_exists?(:featured_works, :generic_file_id) + rename_column :featured_works, :generic_file_id, :work_id + end +end diff --git a/db/migrate/20240815211229_add_arkivo_to_users.hyrax.rb b/db/migrate/20240815211229_add_arkivo_to_users.hyrax.rb new file mode 100644 index 00000000..9f2a67d3 --- /dev/null +++ b/db/migrate/20240815211229_add_arkivo_to_users.hyrax.rb @@ -0,0 +1,8 @@ +class AddArkivoToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :arkivo_token, :string + add_column :users, :arkivo_subscription, :string + add_column :users, :zotero_token, :binary + add_column :users, :zotero_userid, :string + end +end diff --git a/db/migrate/20240815211230_create_sipity.hyrax.rb b/db/migrate/20240815211230_create_sipity.hyrax.rb new file mode 100644 index 00000000..4f53441a --- /dev/null +++ b/db/migrate/20240815211230_create_sipity.hyrax.rb @@ -0,0 +1,163 @@ +class CreateSipity < ActiveRecord::Migration[6.1] + def change + create_table "sipity_notification_recipients" do |t| + t.integer "notification_id", null: false + t.integer "role_id", null: false + t.string "recipient_strategy", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_notification_recipients", ["notification_id", "role_id", "recipient_strategy"], name: "sipity_notifications_recipients_surrogate" + add_index "sipity_notification_recipients", ["notification_id"], name: "sipity_notification_recipients_notification" + add_index "sipity_notification_recipients", ["recipient_strategy"], name: "sipity_notification_recipients_recipient_strategy" + add_index "sipity_notification_recipients", ["role_id"], name: "sipity_notification_recipients_role" + + create_table "sipity_notifications" do |t| + t.string "name", null: false + t.string "notification_type", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_notifications", ["name"], name: "index_sipity_notifications_on_name", unique: true + add_index "sipity_notifications", ["notification_type"], name: "index_sipity_notifications_on_notification_type" + + create_table "sipity_notifiable_contexts" do |t| + t.integer "scope_for_notification_id", null: false + t.string "scope_for_notification_type", null: false + t.string "reason_for_notification", null: false + t.integer "notification_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_notifiable_contexts", ["notification_id"], name: "sipity_notifiable_contexts_notification_id" + add_index "sipity_notifiable_contexts", ["scope_for_notification_id", "scope_for_notification_type", "reason_for_notification", "notification_id"], name: "sipity_notifiable_contexts_concern_surrogate", unique: true + add_index "sipity_notifiable_contexts", ["scope_for_notification_id", "scope_for_notification_type", "reason_for_notification"], name: "sipity_notifiable_contexts_concern_context" + add_index "sipity_notifiable_contexts", ["scope_for_notification_id", "scope_for_notification_type"], name: "sipity_notifiable_contexts_concern" + + create_table "sipity_agents" do |t| + t.string "proxy_for_id", null: false + t.string "proxy_for_type", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_agents", ["proxy_for_id", "proxy_for_type"], name: "sipity_agents_proxy_for", unique: true + + create_table "sipity_comments" do |t| + t.integer "entity_id", null: false + t.integer "agent_id", null: false + t.text "comment" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_comments", ["agent_id"], name: "index_sipity_comments_on_agent_id" + add_index "sipity_comments", ["created_at"], name: "index_sipity_comments_on_created_at" + add_index "sipity_comments", ["entity_id"], name: "index_sipity_comments_on_entity_id" + + create_table "sipity_entities" do |t| + t.string "proxy_for_global_id", null: false + t.integer "workflow_id", null: false + t.integer "workflow_state_id", null: true + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_entities", ["proxy_for_global_id"], name: "sipity_entities_proxy_for_global_id", unique: true + add_index "sipity_entities", ["workflow_id"], name: "index_sipity_entities_on_workflow_id" + add_index "sipity_entities", ["workflow_state_id"], name: "index_sipity_entities_on_workflow_state_id" + + create_table "sipity_entity_specific_responsibilities" do |t| + t.integer "workflow_role_id", null: false + t.string "entity_id", null: false + t.integer "agent_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_entity_specific_responsibilities", ["agent_id"], name: "sipity_entity_specific_responsibilities_agent" + add_index "sipity_entity_specific_responsibilities", ["entity_id"], name: "sipity_entity_specific_responsibilities_entity" + add_index "sipity_entity_specific_responsibilities", ["workflow_role_id", "entity_id", "agent_id"], name: "sipity_entity_specific_responsibilities_aggregate", unique: true + add_index "sipity_entity_specific_responsibilities", ["workflow_role_id"], name: "sipity_entity_specific_responsibilities_role" + + create_table "sipity_workflows" do |t| + t.string "name", null: false + t.string "label" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflows", ["name"], name: "index_sipity_workflows_on_name", unique: true + + create_table "sipity_workflow_actions" do |t| + t.integer "workflow_id", null: false + t.integer "resulting_workflow_state_id" + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_actions", ["resulting_workflow_state_id"], name: "sipity_workflow_actions_resulting_workflow_state" + add_index "sipity_workflow_actions", ["workflow_id", "name"], name: "sipity_workflow_actions_aggregate", unique: true + add_index "sipity_workflow_actions", ["workflow_id"], name: "sipity_workflow_actions_workflow" + + create_table "sipity_workflow_responsibilities" do |t| + t.integer "agent_id", null: false + t.integer "workflow_role_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_responsibilities", ["agent_id", "workflow_role_id"], name: "sipity_workflow_responsibilities_aggregate", unique: true + + create_table "sipity_workflow_roles" do |t| + t.integer "workflow_id", null: false + t.integer "role_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_roles", ["workflow_id", "role_id"], name: "sipity_workflow_roles_aggregate", unique: true + + create_table "sipity_workflow_state_action_permissions" do |t| + t.integer "workflow_role_id", null: false + t.integer "workflow_state_action_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_state_action_permissions", ["workflow_role_id", "workflow_state_action_id"], name: "sipity_workflow_state_action_permissions_aggregate", unique: true + + create_table "sipity_workflow_state_actions" do |t| + t.integer "originating_workflow_state_id", null: false + t.integer "workflow_action_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_state_actions", ["originating_workflow_state_id", "workflow_action_id"], name: "sipity_workflow_state_actions_aggregate", unique: true + + create_table "sipity_workflow_states" do |t| + t.integer "workflow_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_workflow_states", ["name"], name: "index_sipity_workflow_states_on_name" + add_index "sipity_workflow_states", ["workflow_id", "name"], name: "sipity_type_state_aggregate", unique: true + + create_table "sipity_roles" do |t| + t.string "name", null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "sipity_roles", ["name"], name: "index_sipity_roles_on_name", unique: true + end +end diff --git a/db/migrate/20240815211231_create_sipity_workflow_methods.hyrax.rb b/db/migrate/20240815211231_create_sipity_workflow_methods.hyrax.rb new file mode 100644 index 00000000..b6ed4358 --- /dev/null +++ b/db/migrate/20240815211231_create_sipity_workflow_methods.hyrax.rb @@ -0,0 +1,10 @@ +class CreateSipityWorkflowMethods < ActiveRecord::Migration[6.1] + def change + create_table :sipity_workflow_methods do |t| + t.string "service_name", null: false + t.integer "weight", null: false + t.integer "workflow_action_id", index: true, null: false + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211232_create_permission_template.hyrax.rb b/db/migrate/20240815211232_create_permission_template.hyrax.rb new file mode 100644 index 00000000..eb5284c0 --- /dev/null +++ b/db/migrate/20240815211232_create_permission_template.hyrax.rb @@ -0,0 +1,11 @@ +class CreatePermissionTemplate < ActiveRecord::Migration[6.1] + def change + create_table :permission_templates do |t| + t.belongs_to :workflow + t.string :admin_set_id + t.string :visibility + t.timestamps + end + add_index :permission_templates, :admin_set_id + end +end diff --git a/db/migrate/20240815211233_create_permission_template_access.hyrax.rb b/db/migrate/20240815211233_create_permission_template_access.hyrax.rb new file mode 100644 index 00000000..487e0b77 --- /dev/null +++ b/db/migrate/20240815211233_create_permission_template_access.hyrax.rb @@ -0,0 +1,11 @@ +class CreatePermissionTemplateAccess < ActiveRecord::Migration[6.1] + def change + create_table :permission_template_accesses do |t| + t.references :permission_template, foreign_key: true + t.string :agent_type + t.string :agent_id + t.string :access + t.timestamps + end + end +end diff --git a/db/migrate/20240815211234_add_release_to_permission_templates.hyrax.rb b/db/migrate/20240815211234_add_release_to_permission_templates.hyrax.rb new file mode 100644 index 00000000..85573ee3 --- /dev/null +++ b/db/migrate/20240815211234_add_release_to_permission_templates.hyrax.rb @@ -0,0 +1,6 @@ +class AddReleaseToPermissionTemplates < ActiveRecord::Migration[6.1] + def change + add_column :permission_templates, :release_date, :date + add_column :permission_templates, :release_period, :string + end +end diff --git a/db/migrate/20240815211235_add_permission_template_to_sipity_workflow.hyrax.rb b/db/migrate/20240815211235_add_permission_template_to_sipity_workflow.hyrax.rb new file mode 100644 index 00000000..332d156a --- /dev/null +++ b/db/migrate/20240815211235_add_permission_template_to_sipity_workflow.hyrax.rb @@ -0,0 +1,26 @@ +class AddPermissionTemplateToSipityWorkflow < ActiveRecord::Migration[6.1] + def change + add_column :sipity_workflows, :permission_template_id, :integer, index: true + remove_index :sipity_workflows, :name + add_index :sipity_workflows, [:permission_template_id, :name], name: :index_sipity_workflows_on_permission_template_and_name, unique: true + remove_index :permission_templates, :admin_set_id + add_index :permission_templates, :admin_set_id, unique: true + + # Only allow one to be true; Note the options should be nil or true to enforce uniqueness + add_column :sipity_workflows, :active, :boolean, default: nil, index: :unique + + # Doing an inline data migration + begin + if Hyrax::PermissionTemplate.column_names.include?('workflow_id') + Hyrax::PermissionTemplate.each do |permission_template| + workflow_id = permission_template.workflow_id + next unless workflow_id + Sipity::Workflow.find(workflow_id).update(active: true) + end + remove_column :permission_templates, :workflow_id + end + rescue + # It's okay, we didn't have the column + end + end +end diff --git a/db/migrate/20240815211236_tidy_up_because_of_bad_exception.hyrax.rb b/db/migrate/20240815211236_tidy_up_because_of_bad_exception.hyrax.rb new file mode 100644 index 00000000..1485fccb --- /dev/null +++ b/db/migrate/20240815211236_tidy_up_because_of_bad_exception.hyrax.rb @@ -0,0 +1,13 @@ +class TidyUpBecauseOfBadException < ActiveRecord::Migration[6.1] + def change + if column_exists?(Hyrax::PermissionTemplate.table_name, :workflow_id) + Hyrax::PermissionTemplate.all.each do |permission_template| + workflow_id = permission_template.workflow_id + next unless workflow_id + Sipity::Workflow.find(workflow_id).update(active: true) + end + + remove_column Hyrax::PermissionTemplate.table_name, :workflow_id + end + end +end diff --git a/db/migrate/20240815211237_add_allows_access_grant_to_workflow.hyrax.rb b/db/migrate/20240815211237_add_allows_access_grant_to_workflow.hyrax.rb new file mode 100644 index 00000000..5c4f2678 --- /dev/null +++ b/db/migrate/20240815211237_add_allows_access_grant_to_workflow.hyrax.rb @@ -0,0 +1,5 @@ +class AddAllowsAccessGrantToWorkflow < ActiveRecord::Migration[6.1] + def change + add_column :sipity_workflows, :allows_access_grant, :boolean + end +end diff --git a/db/migrate/20240815211238_change_checksum_audit_log.hyrax.rb b/db/migrate/20240815211238_change_checksum_audit_log.hyrax.rb new file mode 100644 index 00000000..73c05c57 --- /dev/null +++ b/db/migrate/20240815211238_change_checksum_audit_log.hyrax.rb @@ -0,0 +1,18 @@ +class ChangeChecksumAuditLog < ActiveRecord::Migration[6.1] + def change + rename_column :checksum_audit_logs, :version, :checked_uri + add_column :checksum_audit_logs, :passed, :boolean + + reversible do |dir| + dir.up do + execute 'UPDATE checksum_audit_logs SET passed = (pass = 1)' + end + dir.down do + execute 'UPDATE checksum_audit_logs SET pass = CASE WHEN passed THEN 1 ELSE 0 END' + end + end + + remove_column :checksum_audit_logs, :pass + add_index :checksum_audit_logs, :checked_uri + end +end diff --git a/db/migrate/20240815211239_create_job_io_wrappers.hyrax.rb b/db/migrate/20240815211239_create_job_io_wrappers.hyrax.rb new file mode 100644 index 00000000..84ef2731 --- /dev/null +++ b/db/migrate/20240815211239_create_job_io_wrappers.hyrax.rb @@ -0,0 +1,15 @@ +class CreateJobIoWrappers < ActiveRecord::Migration[6.1] + def change + create_table :job_io_wrappers do |t| + t.references :user + t.references :uploaded_file + t.string :file_set_id + t.string :mime_type + t.string :original_name + t.string :path + t.string :relation + + t.timestamps + end + end +end diff --git a/db/migrate/20240815211240_create_collection_types.hyrax.rb b/db/migrate/20240815211240_create_collection_types.hyrax.rb new file mode 100644 index 00000000..8cccb414 --- /dev/null +++ b/db/migrate/20240815211240_create_collection_types.hyrax.rb @@ -0,0 +1,17 @@ +class CreateCollectionTypes < ActiveRecord::Migration[6.1] + def change + create_table :hyrax_collection_types do |t| + t.string :title + t.text :description + t.string :machine_id + t.boolean :nestable, null: false, default: true + t.boolean :discovery, null: false, default: true + t.boolean :sharing, null: false, default: true + t.boolean :multiple_membership, null: false, default: true + t.boolean :require_membership, null: false, default: false + t.boolean :workflow, null: false, default: false + t.boolean :visibility, null: false, default: false + end + add_index :hyrax_collection_types, :machine_id + end +end diff --git a/db/migrate/20240815211241_update_collection_type_column_names.hyrax.rb b/db/migrate/20240815211241_update_collection_type_column_names.hyrax.rb new file mode 100644 index 00000000..443ff68e --- /dev/null +++ b/db/migrate/20240815211241_update_collection_type_column_names.hyrax.rb @@ -0,0 +1,9 @@ +class UpdateCollectionTypeColumnNames < ActiveRecord::Migration[6.1] + def change + rename_column :hyrax_collection_types, :discovery, :discoverable + rename_column :hyrax_collection_types, :sharing, :sharable + rename_column :hyrax_collection_types, :multiple_membership, :allow_multiple_membership + rename_column :hyrax_collection_types, :workflow, :assigns_workflow + rename_column :hyrax_collection_types, :visibility, :assigns_visibility + end +end diff --git a/db/migrate/20240815211242_update_collection_type_column_options.hyrax.rb b/db/migrate/20240815211242_update_collection_type_column_options.hyrax.rb new file mode 100644 index 00000000..0ccc1125 --- /dev/null +++ b/db/migrate/20240815211242_update_collection_type_column_options.hyrax.rb @@ -0,0 +1,17 @@ +class UpdateCollectionTypeColumnOptions < ActiveRecord::Migration[6.1] + def up + change_column :hyrax_collection_types, :title, :string, unique: true + change_column :hyrax_collection_types, :machine_id, :string, unique: true + + remove_index :hyrax_collection_types, :machine_id + add_index :hyrax_collection_types, :machine_id, unique: true + end + + def down + change_column :hyrax_collection_types, :title, :string + change_column :hyrax_collection_types, :machine_id, :string + + remove_index :hyrax_collection_types, :machine_id + add_index :hyrax_collection_types, :machine_id + end +end diff --git a/db/migrate/20240815211243_create_collection_branding_infos.hyrax.rb b/db/migrate/20240815211243_create_collection_branding_infos.hyrax.rb new file mode 100644 index 00000000..630363e9 --- /dev/null +++ b/db/migrate/20240815211243_create_collection_branding_infos.hyrax.rb @@ -0,0 +1,15 @@ +class CreateCollectionBrandingInfos < ActiveRecord::Migration[6.1] + def change + create_table :collection_branding_infos do |t| + t.string :collection_id + t.string :role + t.string :local_path + t.string :alt_text + t.string :target_url + t.integer :height + t.integer :width + + t.timestamps + end + end +end diff --git a/db/migrate/20240815211244_create_collection_type_participants.hyrax.rb b/db/migrate/20240815211244_create_collection_type_participants.hyrax.rb new file mode 100644 index 00000000..afd5cade --- /dev/null +++ b/db/migrate/20240815211244_create_collection_type_participants.hyrax.rb @@ -0,0 +1,11 @@ +class CreateCollectionTypeParticipants < ActiveRecord::Migration[6.1] + def change + create_table :collection_type_participants do |t| + t.references :hyrax_collection_type, foreign_key: true, index: {:name => "hyrax_collection_type_id"} + t.string :agent_type + t.string :agent_id + t.string :access + t.timestamps + end + end +end diff --git a/db/migrate/20240815211245_rename_admin_set_id_to_source_id.hyrax.rb b/db/migrate/20240815211245_rename_admin_set_id_to_source_id.hyrax.rb new file mode 100644 index 00000000..20649320 --- /dev/null +++ b/db/migrate/20240815211245_rename_admin_set_id_to_source_id.hyrax.rb @@ -0,0 +1,5 @@ +class RenameAdminSetIdToSourceId < ActiveRecord::Migration[6.1] + def change + rename_column :permission_templates, :admin_set_id, :source_id + end +end diff --git a/db/migrate/20240815211246_add_preferred_locale_to_users.hyrax.rb b/db/migrate/20240815211246_add_preferred_locale_to_users.hyrax.rb new file mode 100644 index 00000000..80f1e5b9 --- /dev/null +++ b/db/migrate/20240815211246_add_preferred_locale_to_users.hyrax.rb @@ -0,0 +1,5 @@ +class AddPreferredLocaleToUsers < ActiveRecord::Migration[6.1] + def change + add_column :users, :preferred_locale, :string + end +end diff --git a/db/migrate/20240815211247_add_collection_type_sharing_options.hyrax.rb b/db/migrate/20240815211247_add_collection_type_sharing_options.hyrax.rb new file mode 100644 index 00000000..35920c60 --- /dev/null +++ b/db/migrate/20240815211247_add_collection_type_sharing_options.hyrax.rb @@ -0,0 +1,5 @@ +class AddCollectionTypeSharingOptions < ActiveRecord::Migration[6.1] + def change + add_column :hyrax_collection_types, :share_applies_to_new_works, :boolean, null: false, default: true + end +end diff --git a/db/migrate/20240815211248_add_unique_constraint_to_permission_template_accesses.hyrax.rb b/db/migrate/20240815211248_add_unique_constraint_to_permission_template_accesses.hyrax.rb new file mode 100644 index 00000000..eecd49b7 --- /dev/null +++ b/db/migrate/20240815211248_add_unique_constraint_to_permission_template_accesses.hyrax.rb @@ -0,0 +1,8 @@ +class AddUniqueConstraintToPermissionTemplateAccesses < ActiveRecord::Migration[6.1] + def change + add_index :permission_template_accesses, + [:permission_template_id, :agent_id, :agent_type, :access], + unique: true, + name: 'uk_permission_template_accesses' + end +end diff --git a/db/migrate/20240815211249_add_branding_to_collection_type.hyrax.rb b/db/migrate/20240815211249_add_branding_to_collection_type.hyrax.rb new file mode 100644 index 00000000..233e5574 --- /dev/null +++ b/db/migrate/20240815211249_add_branding_to_collection_type.hyrax.rb @@ -0,0 +1,5 @@ +class AddBrandingToCollectionType < ActiveRecord::Migration[6.1] + def change + add_column :hyrax_collection_types, :brandable, :boolean, null: false, default: true + end +end diff --git a/db/migrate/20240815211250_add_badge_color_to_collection_types.hyrax.rb b/db/migrate/20240815211250_add_badge_color_to_collection_types.hyrax.rb new file mode 100644 index 00000000..67c882bd --- /dev/null +++ b/db/migrate/20240815211250_add_badge_color_to_collection_types.hyrax.rb @@ -0,0 +1,5 @@ +class AddBadgeColorToCollectionTypes < ActiveRecord::Migration[6.1] + def change + add_column :hyrax_collection_types, :badge_color, :string, default: '#663333' + end +end diff --git a/db/migrate/20240815211251_update_single_use_links_column_names.hyrax.rb b/db/migrate/20240815211251_update_single_use_links_column_names.hyrax.rb new file mode 100644 index 00000000..2d4416be --- /dev/null +++ b/db/migrate/20240815211251_update_single_use_links_column_names.hyrax.rb @@ -0,0 +1,6 @@ +class UpdateSingleUseLinksColumnNames < ActiveRecord::Migration[6.1] + def change + rename_column :single_use_links, :downloadKey, :download_key + rename_column :single_use_links, :itemId, :item_id + end +end diff --git a/db/migrate/20240815211252_change_sipity_entity_specific_responsibility.hyrax.rb b/db/migrate/20240815211252_change_sipity_entity_specific_responsibility.hyrax.rb new file mode 100644 index 00000000..de5d87dc --- /dev/null +++ b/db/migrate/20240815211252_change_sipity_entity_specific_responsibility.hyrax.rb @@ -0,0 +1,9 @@ +class ChangeSipityEntitySpecificResponsibility < ActiveRecord::Migration[6.1] + def change + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + change_column :sipity_entity_specific_responsibilities, :entity_id, 'integer USING CAST(entity_id AS integer)' + else + change_column :sipity_entity_specific_responsibilities, :entity_id, :integer + end + end +end diff --git a/db/migrate/20240815211253_create_default_administrative_set.hyrax.rb b/db/migrate/20240815211253_create_default_administrative_set.hyrax.rb new file mode 100644 index 00000000..4128f9ab --- /dev/null +++ b/db/migrate/20240815211253_create_default_administrative_set.hyrax.rb @@ -0,0 +1,8 @@ +class CreateDefaultAdministrativeSet < ActiveRecord::Migration[6.1] + def change + create_table :hyrax_default_administrative_set do |t| + t.string :default_admin_set_id, null: false + t.timestamps null: false + end + end +end diff --git a/db/migrate/20240815211254_create_hyrax_counter_metrics.hyrax.rb b/db/migrate/20240815211254_create_hyrax_counter_metrics.hyrax.rb new file mode 100644 index 00000000..80caf88c --- /dev/null +++ b/db/migrate/20240815211254_create_hyrax_counter_metrics.hyrax.rb @@ -0,0 +1,14 @@ +class CreateHyraxCounterMetrics < ActiveRecord::Migration[6.1] + def change + create_table :hyrax_counter_metrics do |t| + t.string :worktype + t.string :resource_type + t.integer :work_id + t.date :date + t.integer :total_item_investigations + t.integer :total_item_requests + + t.timestamps + end + end +end diff --git a/db/migrate/20240815211255_change_work_id_to_string.hyrax.rb b/db/migrate/20240815211255_change_work_id_to_string.hyrax.rb new file mode 100644 index 00000000..1cdb92a3 --- /dev/null +++ b/db/migrate/20240815211255_change_work_id_to_string.hyrax.rb @@ -0,0 +1,5 @@ +class ChangeWorkIdToString < ActiveRecord::Migration[6.1] + def change + change_column :hyrax_counter_metrics, :work_id, :string + end +end diff --git a/db/migrate/20240815211256_add_indices_to_hyrax_counter_metrics.hyrax.rb b/db/migrate/20240815211256_add_indices_to_hyrax_counter_metrics.hyrax.rb new file mode 100644 index 00000000..b71e0977 --- /dev/null +++ b/db/migrate/20240815211256_add_indices_to_hyrax_counter_metrics.hyrax.rb @@ -0,0 +1,8 @@ +class AddIndicesToHyraxCounterMetrics < ActiveRecord::Migration[6.1] + def change + add_index :hyrax_counter_metrics, :worktype + add_index :hyrax_counter_metrics, :resource_type + add_index :hyrax_counter_metrics, :work_id + add_index :hyrax_counter_metrics, :date + end +end diff --git a/db/migrate/20240815211257_add_fields_to_counter_metric.hyrax.rb b/db/migrate/20240815211257_add_fields_to_counter_metric.hyrax.rb new file mode 100644 index 00000000..7b2ec02f --- /dev/null +++ b/db/migrate/20240815211257_add_fields_to_counter_metric.hyrax.rb @@ -0,0 +1,8 @@ +class AddFieldsToCounterMetric < ActiveRecord::Migration[6.1] + def change + add_column :hyrax_counter_metrics, :title, :string + add_column :hyrax_counter_metrics, :year_of_publication, :integer, index: true + add_column :hyrax_counter_metrics, :publisher, :string, index: true + add_column :hyrax_counter_metrics, :author, :string, index: true + end +end diff --git a/lib/active_job_tenant.rb b/lib/active_job_tenant.rb index fec07c64..c40c09a3 100644 --- a/lib/active_job_tenant.rb +++ b/lib/active_job_tenant.rb @@ -50,19 +50,19 @@ def perform_now private - delegate :non_tenant_job?, to: :class + delegate :non_tenant_job?, to: :class - def current_account - @current_account ||= Account.find_by(tenant: current_tenant) - end + def current_account + @current_account ||= Account.find_by(tenant: current_tenant) + end - def current_tenant - tenant || Apartment::Tenant.current - end + def current_tenant + tenant || Apartment::Tenant.current + end - def switch - Apartment::Tenant.switch(current_tenant) do - yield - end + def switch + Apartment::Tenant.switch(current_tenant) do + yield end + end end diff --git a/lib/dog_biscuits/actors/apply_authorities.rb b/lib/dog_biscuits/actors/apply_authorities.rb index 516452b3..d183855e 100644 --- a/lib/dog_biscuits/actors/apply_authorities.rb +++ b/lib/dog_biscuits/actors/apply_authorities.rb @@ -5,28 +5,28 @@ module Actors module ApplyAuthorities private - # Add new terms to table-based authorities - # - # @param env [Hyrax::Actors::Environment] the env - def apply_authorities(env) - DogBiscuits.config.authorities_add_new.each do |authority_name| - term = authority_name.to_s.singularize.to_sym - next unless env.attributes.key? term - env.attributes[term].each do |attr| - add_new(authority_name.to_s, attr) - end + # Add new terms to table-based authorities + # + # @param env [Hyrax::Actors::Environment] the env + def apply_authorities(env) + DogBiscuits.config.authorities_add_new.each do |authority_name| + term = authority_name.to_s.singularize.to_sym + next unless env.attributes.key? term + env.attributes[term].each do |attr| + add_new(authority_name.to_s, attr) end end + end - # Add new term to the authority; it will be rejected if already present - # - # @param auth [String] the authority to add to - # @param label [String] the label to add - def add_new(authority_name, label) - DogBiscuits::Importers::Authority.new(authority_name).create_record(label) if Qa::Authorities::Local.subauthority_for(authority_name).search(label).empty? - rescue Qa::InvalidSubAuthority - Rails.logger.error("Invalid sub-authority: #{auth}") - end + # Add new term to the authority; it will be rejected if already present + # + # @param auth [String] the authority to add to + # @param label [String] the label to add + def add_new(authority_name, label) + DogBiscuits::Importers::Authority.new(authority_name).create_record(label) if Qa::Authorities::Local.subauthority_for(authority_name).search(label).empty? + rescue Qa::InvalidSubAuthority + Rails.logger.error("Invalid sub-authority: #{auth}") + end end end end diff --git a/lib/dog_biscuits/property_mappings/property_mappings.rb b/lib/dog_biscuits/property_mappings/property_mappings.rb index e81a27e0..dd41cf2c 100644 --- a/lib/dog_biscuits/property_mappings/property_mappings.rb +++ b/lib/dog_biscuits/property_mappings/property_mappings.rb @@ -297,7 +297,7 @@ def property_mappings label: 'Journal name' }, keyword: { - index: [{ link_to_search: true }], + index: [{ link_to_search: true }], label: 'Keywords', schema_org: { property: "keywords" @@ -305,7 +305,7 @@ def property_mappings help_text: "Words or phrases you select to describe what the work is about. These are used to search for content." }, language: { - index: [{ link_to_search: true }], + index: [{ link_to_search: true }], label: 'Language', schema_org: { property: "language" diff --git a/spec/forms/hyrax/forms/collection_form_decorator_spec.rb b/spec/forms/hyrax/forms/collection_form_decorator_spec.rb index ad900e98..eefd9418 100644 --- a/spec/forms/hyrax/forms/collection_form_decorator_spec.rb +++ b/spec/forms/hyrax/forms/collection_form_decorator_spec.rb @@ -11,7 +11,7 @@ let(:repository) { double } # TODO: convert this to a valkyrie test. the factory is creating a valkyrie - # object which is why this fails now. + # object which is why this fails now. xit { is_expected.not_to respond_to :alternative_title } describe 'calling #alternative_title' do diff --git a/spec/services/adventist/text_file_text_extraction_service_spec.rb b/spec/services/adventist/text_file_text_extraction_service_spec.rb index 7791beb7..a1d936ed 100644 --- a/spec/services/adventist/text_file_text_extraction_service_spec.rb +++ b/spec/services/adventist/text_file_text_extraction_service_spec.rb @@ -21,7 +21,7 @@ end describe 'position in the array of Hyrax::DerivativeService.services' do - # TODO: inspect why this is failing + # TODO: inspect why this is failing xit "is in the first position" do expect(Hyrax::DerivativeService.services).to( match_array( diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0e0941bd..ec7b7744 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,4 +12,4 @@ end require File.expand_path("hyku_specs/rails_helper.rb", __dir__) -require File.expand_path("hyku_specs/spec_helper.rb", __dir__) \ No newline at end of file +require File.expand_path("hyku_specs/spec_helper.rb", __dir__) From 2a0fe2e67c1726bc464da5f8b6a4a966bc6e7183 Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Mon, 19 Aug 2024 09:46:27 -0700 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=92=84=20Fixing=20linting=20for=20Adv?= =?UTF-8?q?entist=20Valkyrie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit excludes the hash alignment cop from the decorator file. There was a previous pattern established concerning hash alignments that conflicted with Rubocop's standards. We will be staying with the established pattern in the application. Ref: - https://github.com/scientist-softserv/adventist_knapsack/issues/741 --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 73741d6c..68fbac5e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,6 +15,10 @@ AllCops: - 'vendor/**/*' - 'lib/tasks/rubocop.rake' +Layout/HashAlignment: + Exclude: + - app/forms/hyrax/forms/admin/adl_appearance_decorator.rb + Metrics/BlockLength: IgnoredMethods: ['included', 'describe', 'it', 'context'] Exclude: From b474be903f92bbf25aec62ec048fc54d2b21b85c Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Mon, 19 Aug 2024 11:11:06 -0700 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=92=84=20Fixing=20linting=20for=20Adv?= =?UTF-8?q?entist=20Valkyrie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates depricated Rubocop syntax. `IgnoredMethods` for `Metrics/BlockLength` in the file `rubocop.yml` is replaced with `AllowedMethods`. `Metrics/LineLength` is replaced with `Layout/LineLength` in all appropriate files. Ref: - https://github.com/scientist-softserv/adventist_knapsack/issues/741 --- .rubocop.yml | 2 +- .rubocop_todo.yml | 2 +- .../actors/collections_membership_actor.rb | 4 ++-- ...create_with_remote_files_actor_decorator.rb | 6 +++--- app/indexers/app_indexer_decorator.rb | 4 ++-- app/jobs/characterize_job.rb | 4 ++-- app/jobs/create_derivatives_job_decorator.rb | 4 ++-- app/jobs/file_sets_reprocess_job.rb | 4 ++-- .../child_works_from_pdf_job_decorator.rb | 2 +- config/initializers/iiif_print.rb | 4 ++-- .../property_mappings/property_mappings.rb | 4 ++-- lib/hyku_knapsack/engine.rb | 4 ++-- .../jobs/collection_membership_job.rb | 8 ++++---- sdapi_ingest_scripts/jobs/rerun_entry_job.rb | 4 ++-- .../rerun_errored_entries_for_importer_job.rb | 18 +++++++++--------- spec/config/initializers/iiif_print_spec.rb | 4 ++-- spec/config/initializers/slug_override_spec.rb | 4 ++-- .../catalog_controller_decorator_spec.rb | 4 ++-- spec/features/create_conference_item_spec.rb | 4 ++-- spec/features/create_dataset_spec.rb | 4 ++-- spec/features/create_exam_paper_spec.rb | 4 ++-- spec/features/create_journal_article_spec.rb | 4 ++-- spec/features/create_published_work_spec.rb | 4 ++-- spec/features/create_thesis_spec.rb | 4 ++-- spec/features/facet_by_year_spec.rb | 4 ++-- .../bulkrax/oai_adventist_qdc_entry_spec.rb | 4 ++-- .../bulkrax/oai_adventist_set_entry_spec.rb | 4 ++-- 27 files changed, 61 insertions(+), 61 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 68fbac5e..8eb3af3d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -20,7 +20,7 @@ Layout/HashAlignment: - app/forms/hyrax/forms/admin/adl_appearance_decorator.rb Metrics/BlockLength: - IgnoredMethods: ['included', 'describe', 'it', 'context'] + AllowedMethods: ['included', 'describe', 'it', 'context'] Exclude: - "spec/**/*.rb" - app/controllers/catalog_controller_decorator.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 03f021d5..65db5b7d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -27,7 +27,7 @@ Metrics/CyclomaticComplexity: # Offense count: 14 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https -Metrics/LineLength: +Layout/LineLength: Max: 161 # Offense count: 24 diff --git a/app/actors/hyrax/actors/collections_membership_actor.rb b/app/actors/hyrax/actors/collections_membership_actor.rb index 705b340c..f35b7db5 100644 --- a/app/actors/hyrax/actors/collections_membership_actor.rb +++ b/app/actors/hyrax/actors/collections_membership_actor.rb @@ -42,12 +42,12 @@ def assign_nested_attributes_for_collection(env) return true unless attributes_collection # OVERRIDE Hyrax 3.5.0 to skip permission checks if importing - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength return false unless env.importing || valid_membership?(env, collection_ids: attributes_collection.map { |_, attributes| attributes['id'] }) - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } # checking for existing works to avoid rewriting/loading works that are already attached existing_collections = env.curation_concern.member_of_collection_ids diff --git a/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb b/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb index d61de3e5..2bd00433 100644 --- a/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb +++ b/app/actors/hyrax/actors/create_with_remote_files_actor_decorator.rb @@ -28,7 +28,7 @@ def attach! add_ordered_members! if ordered true end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength def create_file_from_url(uri, file_name, auth_header, override_default_thumbnail = nil) import_url = URI.decode_www_form_component(uri.to_s) @@ -50,6 +50,6 @@ def create_file_from_url(uri, file_name, auth_header, override_default_thumbnail end end -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength Hyrax::Actors::CreateWithRemoteFilesActor::IngestRemoteFilesService.prepend Hyrax::Actors::CreateWithRemoteFilesActorDecorator::IngestRemoteFilesServiceDecorator -# rubocop:enable Metrics/LineLength +# rubocop:enable Layout/LineLength diff --git a/app/indexers/app_indexer_decorator.rb b/app/indexers/app_indexer_decorator.rb index 65de8eba..87c22da7 100644 --- a/app/indexers/app_indexer_decorator.rb +++ b/app/indexers/app_indexer_decorator.rb @@ -17,9 +17,9 @@ def generate_solr_document .join("\n---------------------------\n") if object.date_created.present? - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength date_created = object.date_created.is_a?(ActiveTriples::Relation) ? object.date_created.first : object.date_created - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength # expects date created to be array with single string in yyyy-mm-dd format solr_doc['sorted_date_isi'] = date_created.tr('-', '').to_i solr_doc['sorted_month_isi'] = date_created.tr('-', '').slice(0..5).to_i diff --git a/app/jobs/characterize_job.rb b/app/jobs/characterize_job.rb index c82eb5c1..8e0bde88 100644 --- a/app/jobs/characterize_job.rb +++ b/app/jobs/characterize_job.rb @@ -10,7 +10,7 @@ class CharacterizeJob < Hyrax::ApplicationJob # @param [String] file_id identifier for a Hydra::PCDM::File # @param [String, NilClass] filepath the cached file within the Hyrax.config.working_path def perform(file_set, file_id, filepath = nil) - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength raise "#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy? filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath) Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filepath, ch12n_tool: :fits_servlet) @@ -19,6 +19,6 @@ def perform(file_set, file_id, filepath = nil) file_set.update_index file_set.parent&.in_collections&.each(&:update_index) CreateDerivativesJob.perform_later(file_set, file_id, filepath) - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end diff --git a/app/jobs/create_derivatives_job_decorator.rb b/app/jobs/create_derivatives_job_decorator.rb index da821293..e05a7e54 100644 --- a/app/jobs/create_derivatives_job_decorator.rb +++ b/app/jobs/create_derivatives_job_decorator.rb @@ -17,7 +17,7 @@ def perform(file_set, file_id, filepath = nil) # We should not be creating derivatives for thumbnails. FILE_SUFFIXES_TO_SKIP_DERIVATIVE_CREATION = ([] + NON_ARCHIVAL_PDF_SUFFIXES).freeze - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength def self.create_derivative_for?(file_set:) # Our options appear to be `file_set.label` or `file_set.original_file.original_name`; in # favoring `#label` we are avoiding a call to Fedora. Is the label likely to be the original @@ -26,7 +26,7 @@ def self.create_derivative_for?(file_set:) true end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end CreateDerivativesJob.prepend(CreateDerivativesJobDecorator) diff --git a/app/jobs/file_sets_reprocess_job.rb b/app/jobs/file_sets_reprocess_job.rb index 63f283ab..8d59db87 100644 --- a/app/jobs/file_sets_reprocess_job.rb +++ b/app/jobs/file_sets_reprocess_job.rb @@ -83,7 +83,7 @@ class ConditionallyResplitFileSetJob < ApplicationJob # @return [Symbol] A terse explanation of what was done with this job. # # @raise [ActiveFedora::ObjectNotFoundError] when the given FileSet's parent could not be found. - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength def perform(file_set_id:) file_set = FileSetFinder.find(file_set_id:) @@ -109,7 +109,7 @@ def perform(file_set_id:) IiifPrint::Jobs::RequestSplitPdfJob.perform_later(file_set:, user: User.batch_user) :requesting_split end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end ## diff --git a/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb b/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb index c006dbb5..2efb4b27 100644 --- a/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb +++ b/app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb @@ -158,7 +158,7 @@ def resource_types @parent_work.try(:resource_type) end end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end IiifPrint::Jobs::ChildWorksFromPdfJob.prepend(IiifPrint::ChildWorksFromPdfJobDecorator) diff --git a/config/initializers/iiif_print.rb b/config/initializers/iiif_print.rb index 313eb292..e79a224d 100644 --- a/config/initializers/iiif_print.rb +++ b/config/initializers/iiif_print.rb @@ -27,7 +27,7 @@ config.additional_tesseract_options = "-l eng_best" # Reconfigure the title generated by the PDF splitter - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength config.unique_child_title_generator_function = lambda { |original_pdf_path:, parent_work:, page_number:, page_padding:, **| identifier = parent_work.to_param # ref Slug Bug filename = File.basename(original_pdf_path) @@ -131,7 +131,7 @@ params.merge!(embargo_params).merge!(lease_params).merge!(visibility_params) end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end require "iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter" diff --git a/lib/dog_biscuits/property_mappings/property_mappings.rb b/lib/dog_biscuits/property_mappings/property_mappings.rb index dd41cf2c..b44ccb3c 100644 --- a/lib/dog_biscuits/property_mappings/property_mappings.rb +++ b/lib/dog_biscuits/property_mappings/property_mappings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/ModuleLength @@ -580,6 +580,6 @@ def property_mappings end end -# rubocop:enable Metrics/LineLength +# rubocop:enable Layout/LineLength # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/ModuleLength diff --git a/lib/hyku_knapsack/engine.rb b/lib/hyku_knapsack/engine.rb index 6c8e30fd..fe88fe5a 100644 --- a/lib/hyku_knapsack/engine.rb +++ b/lib/hyku_knapsack/engine.rb @@ -110,13 +110,13 @@ def self.load_translations! # In the development environment we may not have AWS credentials. When we do, let's use s3. When # we don't, we'll use local files (which almost certainly will fail). This means we'd be locally # using the derivative rodeo's splitting process (which should work without a preprocess lcoation). - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength IiifPrint::DerivativeRodeoService.preprocessed_location_adapter_name = if DerivativeRodeo.config.aws_s3_access_key_id.present? && DerivativeRodeo.config.aws_s3_secret_access_key.present? 's3' else 'file' end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end # rubocop:enable Metrics/BlockLength diff --git a/sdapi_ingest_scripts/jobs/collection_membership_job.rb b/sdapi_ingest_scripts/jobs/collection_membership_job.rb index 67e75a94..86f3a67c 100644 --- a/sdapi_ingest_scripts/jobs/collection_membership_job.rb +++ b/sdapi_ingest_scripts/jobs/collection_membership_job.rb @@ -9,11 +9,11 @@ class CollectionMembershipJob < ApplicationJob retry_on StandardError, attempts: 0 - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength COLLECTIONS_TO_REMOVE = [ "2487c594-1026-4a91-9ede-6105d5626a41", "67911ae1-8a26-4309-ba89-aca81c2fe3be", "4b298df0-9147-4990-a08d-0f53cbc90ed6", "be482035-fe21-4be0-9704-c422618b4525", "0c0444c4-9642-447d-b912-ae7de4163342", "a68b1cff-47c7-4f4d-9e1c-70c05ba48512", "608cca3c-9780-4842-b5f4-79bfcea8eb02", "36e07892-4167-4cb1-b0a8-986cfd1edbd6", "0b10fed9-51dd-48dd-89e1-dd990e94e1fc", "254bd824-7e53-400b-a74c-189043e02db8", "36b2f7ec-8750-482c-842c-bf02462fbf5b", "280c499e-7026-4427-b41b-1f594978cbf4", "2be7ac3e-786c-42f5-932b-180ac8ec5fee", "a5df1cbc-33eb-4120-ad93-b9d930a26dc7", "c1f28f13-0a97-42fe-b98e-52b14e26194c", "8647cc37-8434-4d9a-bb66-0d898715c264", "d44b5783-e949-40dd-b7fb-d1ed13cafc5f", "ac2a2de7-6aad-45f5-ab9f-0e7afb345855", "63daa10f-0ffa-4566-913c-f35eef9e077d", "07f8dbf8-06f2-472e-b11b-5efa21451e13" ].freeze - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength # rubocop:disable Metrics/MethodLength def perform(work_type: 'JournalArticle', @@ -41,8 +41,8 @@ def perform(work_type: 'JournalArticle', end # rubocop:enable Metrics/MethodLength - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength Rails.logger.info("💜💜💜 Collection updates for work type #{work_type}: #{wk_count} processed, #{wk_updated} updated.") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end diff --git a/sdapi_ingest_scripts/jobs/rerun_entry_job.rb b/sdapi_ingest_scripts/jobs/rerun_entry_job.rb index 4c30ec67..4672b913 100644 --- a/sdapi_ingest_scripts/jobs/rerun_entry_job.rb +++ b/sdapi_ingest_scripts/jobs/rerun_entry_job.rb @@ -21,8 +21,8 @@ def perform(entry_class_name:, entry_id:) bulkrax_entry.build bulkrax_entry.save - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength Rails.logger.info("Finished re-submitting entry for for #{bulkrax_entry.class} ID=#{bulkrax_entry.id}. entry status=#{bulkrax_entry.status}") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end diff --git a/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb b/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb index b9ce927c..b2048694 100644 --- a/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb +++ b/sdapi_ingest_scripts/jobs/rerun_errored_entries_for_importer_job.rb @@ -52,18 +52,18 @@ def do_it! logger.info("Starting re-importing #{reimport_logging_context} with entries that had any error.") relation = relation.where.not(error_class: nil) else - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength logger.info("Starting re-importing #{reimport_logging_context} with entries that had the following errors: #{error_classes.inspect}.") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength relation = relation.where(error_class: error_classes) end # We need to count before we do the select narrowing; otherwise ActiveRecord will throw a SQL # error. relation_count = relation.count - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength logger.info("*****************Found #{relation_count} entries to re-import for #{reimport_logging_context}.*****************") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength # No sense loading all the fields; we really only need these two values to resubmit the given job. relation = relation.select('id', 'statusable_id', 'statusable_type') @@ -71,16 +71,16 @@ def do_it! relation.find_each do |status| counter += 1 - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength logger.info("Enqueuing re-import for #{reimport_logging_context} #{status.statusable_type} ID=#{status.statusable_id} (#{counter} of #{relation_count}).") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength begin - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength RerunEntryJob.perform_later(entry_class_name: status.statusable_type, entry_id: status.statusable_id) rescue StandardError => e - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength logger.error("😈😈😈 Error: #{e.message} for #{reimport_logging_context} #{status.statusable_type} ID=#{status.statusable_id}") - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength raise e end end diff --git a/spec/config/initializers/iiif_print_spec.rb b/spec/config/initializers/iiif_print_spec.rb index 4484d1f5..0f22e24c 100644 --- a/spec/config/initializers/iiif_print_spec.rb +++ b/spec/config/initializers/iiif_print_spec.rb @@ -38,9 +38,9 @@ subject { build_manifest_method.source_location[0] } # Verify that we're using the app services iiif_print decorator - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength it { is_expected.to eq(HykuKnapsack::Engine.root.join('app', 'services', 'iiif_print', 'manifest_builder_service_behavior_decorator.rb').to_s) } - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end describe 'super_method' do diff --git a/spec/config/initializers/slug_override_spec.rb b/spec/config/initializers/slug_override_spec.rb index 1fff6d99..92cbd887 100644 --- a/spec/config/initializers/slug_override_spec.rb +++ b/spec/config/initializers/slug_override_spec.rb @@ -15,7 +15,7 @@ xit 'deletes via Hyrax::Transactions' do doc_id = work.to_param - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect do resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id)) transactions['collection_resource.destroy'] @@ -23,7 +23,7 @@ .call(resource) .value! end.to change { ActiveFedora::SolrService.query("id:\"#{doc_id}\"", fl: "id", method: :post, rows: 1).count }.from(1).to(0) - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end end diff --git a/spec/controllers/catalog_controller_decorator_spec.rb b/spec/controllers/catalog_controller_decorator_spec.rb index 3416aaa0..065c0e93 100644 --- a/spec/controllers/catalog_controller_decorator_spec.rb +++ b/spec/controllers/catalog_controller_decorator_spec.rb @@ -28,9 +28,9 @@ describe 'solr dictionaries' do it 'does not specified spellcheck.dictionaries' do - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(blacklight_config.search_fields).to(be_none { |_field, config| config&.solr_parameters&.key?('spellcheck.dictionaries'.to_sym) }) - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end end end diff --git a/spec/features/create_conference_item_spec.rb b/spec/features/create_conference_item_spec.rb index 7948a32a..793caece 100644 --- a/spec/features/create_conference_item_spec.rb +++ b/spec/features/create_conference_item_spec.rb @@ -66,9 +66,9 @@ # its element find('body').click choose('conference_item_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength check('agreement') click_on('Save') diff --git a/spec/features/create_dataset_spec.rb b/spec/features/create_dataset_spec.rb index df3b2b8d..51ae8aaf 100644 --- a/spec/features/create_dataset_spec.rb +++ b/spec/features/create_dataset_spec.rb @@ -66,10 +66,10 @@ # its element find('body').click choose('dataset_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') check('agreement') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength click_on('Save') expect(page).to have_content('My Test Work') diff --git a/spec/features/create_exam_paper_spec.rb b/spec/features/create_exam_paper_spec.rb index d3302320..7e5eb102 100644 --- a/spec/features/create_exam_paper_spec.rb +++ b/spec/features/create_exam_paper_spec.rb @@ -66,10 +66,10 @@ # its element find('body').click choose('exam_paper_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') check('agreement') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength click_on('Save') expect(page).to have_content('My Test Work') diff --git a/spec/features/create_journal_article_spec.rb b/spec/features/create_journal_article_spec.rb index a6e7825a..054072c8 100644 --- a/spec/features/create_journal_article_spec.rb +++ b/spec/features/create_journal_article_spec.rb @@ -66,10 +66,10 @@ # its element find('body').click choose('journal_article_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') check('agreement') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength click_on('Save') expect(page).to have_content('My Test Work') diff --git a/spec/features/create_published_work_spec.rb b/spec/features/create_published_work_spec.rb index 5f70650b..a607f691 100644 --- a/spec/features/create_published_work_spec.rb +++ b/spec/features/create_published_work_spec.rb @@ -66,10 +66,10 @@ # its element find('body').click choose('published_work_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') check('agreement') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength click_on('Save') expect(page).to have_content('My Test Work') diff --git a/spec/features/create_thesis_spec.rb b/spec/features/create_thesis_spec.rb index 9debda07..5a058365 100644 --- a/spec/features/create_thesis_spec.rb +++ b/spec/features/create_thesis_spec.rb @@ -66,10 +66,10 @@ # its element find('body').click choose('thesis_visibility_open') - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to') check('agreement') - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength click_on('Save') expect(page).to have_content('My Test Work') diff --git a/spec/features/facet_by_year_spec.rb b/spec/features/facet_by_year_spec.rb index 67199d2a..58d9a6a4 100644 --- a/spec/features/facet_by_year_spec.rb +++ b/spec/features/facet_by_year_spec.rb @@ -250,9 +250,9 @@ end it "displays plot after facet is expanded" do - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength visit "/catalog/range_limit?commit=Limit&locale=en&q=&range_end=2021&range_field=sorted_year_isi&range_start=2&search_field=all_fields" - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength expect(page.status_code).to eq 200 end end diff --git a/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb b/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb index ae706577..24944e4f 100644 --- a/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb +++ b/spec/models/bulkrax/oai_adventist_qdc_entry_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" require "bulkrax/entry_spec_helper" -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength RSpec.describe Bulkrax::OaiAdventistQdcEntry do describe "#build_metadata" do subject(:entry) do @@ -113,4 +113,4 @@ end end end -# rubocop:enable Metrics/LineLength +# rubocop:enable Layout/LineLength diff --git a/spec/models/bulkrax/oai_adventist_set_entry_spec.rb b/spec/models/bulkrax/oai_adventist_set_entry_spec.rb index e08f8bc8..28e7c2e9 100644 --- a/spec/models/bulkrax/oai_adventist_set_entry_spec.rb +++ b/spec/models/bulkrax/oai_adventist_set_entry_spec.rb @@ -16,7 +16,7 @@ let(:identifier) { "20000026" } let(:collection_title) { "Rumah Tangga Dan Kesehatan" } - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:data) do %( @@ -35,7 +35,7 @@ ) end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength it "does not set a pending relationship for the part_of collection" do # This needs to be persisted for saving the entry entry.importer.save!