From 5a3b262fa459b5d30ab38def6e32eadbf3c966ae Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Tue, 5 Dec 2023 13:27:20 +0100 Subject: [PATCH 1/4] Update Yomu gem, add reset protocols creator user assignments and extract missing asset texts rake tasks [SCI-9812] (#6761) --- Gemfile.lock | 2 +- lib/tasks/data.rake | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e41c2e6b8..7191d38a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,7 +50,7 @@ GIT GIT remote: https://github.com/scinote-eln/yomu - revision: 020ab670b2919f3b436e926a890d1dad23d75676 + revision: 09b7b4910f59453970aab03d7b3ddb60b41db89a branch: master specs: yomu (0.2.4) diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 98d3a9450..8caefd19e 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -1,3 +1,7 @@ +# frozen_string_literal: true + +# rubocop:disable Metrics/BlockLength + namespace :data do Rails.logger = Logger.new(STDOUT) @@ -5,7 +9,6 @@ namespace :data do task clean_temp_files: :environment do Rails.logger.info "Cleaning temporary files older than 3 days" TempFile.where("created_at < ?", 3.days.ago).each do |tmp_file| - TempFile.transaction do begin tmp_file.destroy! @@ -194,4 +197,37 @@ namespace :data do end end end + + desc 'Reset protocols creator user assignments' + task reset_protocols_creator_user_assignments: :environment do + ActiveRecord::Base.transaction do + owner_role = UserRole.find_predefined_owner_role + protocols = + Protocol.where(protocol_type: Protocol::REPOSITORY_TYPES) + .joins('LEFT OUTER JOIN "user_assignments" ON "user_assignments"."assignable_type" = \'Protocol\' ' \ + 'AND "user_assignments"."assignable_id" = "protocols"."id" ' \ + 'AND "user_assignments"."assigned" = 1 ' \ + 'AND "user_assignments"."user_id" = "protocols"."added_by_id"') + .where('"user_assignments"."id" IS NULL') + .distinct + protocols.find_each do |protocol| + new_user_assignment = protocol.user_assignments + .find_or_initialize_by(user: protocol.added_by, team: protocol.team) + new_user_assignment.user_role = owner_role + new_user_assignment.assigned_by = protocol.added_by + new_user_assignment.assigned = :manually + new_user_assignment.save! + end + end + end + + desc 'Extract missing asset texts' + task extract_missing_asset_texts: :environment do + Asset.joins(:file_blob) + .where.missing(:asset_text_datum) + .where(file_blob: { content_type: Constants::TEXT_EXTRACT_FILE_TYPES }) + .find_each(&:extract_asset_text) + end end + +# rubocop:enable Metrics/BlockLength From 5c852a1aa4f0f5952d404dbe055f653598a12ad9 Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Fri, 8 Dec 2023 11:29:11 +0100 Subject: [PATCH 2/4] Trigger file text extraction on file update in an inventory [SCI-9842] (#6782) --- app/models/repository_asset_value.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/repository_asset_value.rb b/app/models/repository_asset_value.rb index f619d5cd4..1d76ac298 100644 --- a/app/models/repository_asset_value.rb +++ b/app/models/repository_asset_value.rb @@ -70,6 +70,7 @@ class RepositoryAssetValue < ApplicationRecord asset.last_modified_by = user self.last_modified_by = user asset.save! && save! + asset.post_process_file(repository_cell.repository_column.repository.team) end def snapshot!(cell_snapshot) From b089a85bc53829f72c467fc4cf916d3eb61c57aa Mon Sep 17 00:00:00 2001 From: Alex Kriuchykhin Date: Fri, 8 Dec 2023 11:29:24 +0100 Subject: [PATCH 3/4] Update revision of Yomu gem [SCI-9824] (#6783) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7191d38a8..16d9f6beb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,7 +50,7 @@ GIT GIT remote: https://github.com/scinote-eln/yomu - revision: 09b7b4910f59453970aab03d7b3ddb60b41db89a + revision: fb518a5fbab82f692dea4ae1fdf30eae5df62590 branch: master specs: yomu (0.2.4) From 88543e792d93091a7462b3d769f39f63a0c47b6f Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Fri, 29 Dec 2023 11:36:55 +0100 Subject: [PATCH 4/4] Bump version to 1.28.0.7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b9acb1a38..1e6b3fcf0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.28.0.6 +1.28.0.7