From 0ee7ea9227d23d87010cc3e058a25f34d652e4bd Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 31 Jul 2024 10:20:45 +0100 Subject: [PATCH 01/61] feat: adds novaseq 6000 sequencing request to rvi bcl submission --- .../010_rvi_bait_capture_library_submission_templates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml index 88990aea59..d14fe2a676 100644 --- a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml +++ b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml @@ -4,7 +4,7 @@ Limber-Htp - RVI - Bait Capture Library: submission_class_name: "LinearSubmission" related_records: - request_type_keys: ["limber_bait_capture_library_prep", "limber_multiplexing"] + request_type_keys: ["limber_bait_capture_library_prep", "limber_multiplexing", "illumina_htp_novaseq_6000_paired_end_sequencing"] project_name: Respiratory Virus and Microbiome Initiative product_line_name: Illumina-HTP product_catalogue_name: Bait Capture Library From 3993807a163426a1ca7d9893f9dbf603a3868de2 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 31 Jul 2024 11:36:34 +0100 Subject: [PATCH 02/61] style: linted --- .../010_rvi_bait_capture_library_submission_templates.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml index d14fe2a676..cab17a4fbd 100644 --- a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml +++ b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml @@ -4,7 +4,8 @@ Limber-Htp - RVI - Bait Capture Library: submission_class_name: "LinearSubmission" related_records: - request_type_keys: ["limber_bait_capture_library_prep", "limber_multiplexing", "illumina_htp_novaseq_6000_paired_end_sequencing"] + request_type_keys: + ["limber_bait_capture_library_prep", "limber_multiplexing", "illumina_htp_novaseq_6000_paired_end_sequencing"] project_name: Respiratory Virus and Microbiome Initiative product_line_name: Illumina-HTP product_catalogue_name: Bait Capture Library From 2c4b98f977d2aedfbcbf17cd1fd1a16e8d376754 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:43:11 +0100 Subject: [PATCH 03/61] bug(add_missing_asset_audit_records.rake): Create a rake task to add missing records to asset_audits table from a csv file --- .../add_missing_asset_audit_records.rake | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/tasks/add_missing_asset_audit_records.rake diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake new file mode 100644 index 0000000000..b20c9adb66 --- /dev/null +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +namespace :asset_audit do + desc 'Add missing asset audit records' + task :add_missing_records, [:file_path] => :environment do |_, args| + file_path = args[:file_path] + if file_path.nil? || !File.exist?(file_path) + puts 'Please provide a valid file path' + exit + end + + puts 'Adding missing asset audit records...' + + ActiveRecord::Base.transaction do + csv_data = CSV.read(file_path, headers: true) + csv_data.each do |row| + + asset = Labware.find_by_barcode(row['barcode'].strip) + next if asset.nil? + + key = case row['message'] + when 'Destroying location' + 'destroy_location' + when 'Destroying labware' + 'destroy_labware' + end + next if key.nil? + + begin + AssetAudit.create!( message: "Process '#{row['message']}' performed on instrument Destroying instrument", + created_by: row['created_by'].strip, + created_at: row['created_at'].strip, + asset_id: asset.id, + key:key) + puts "Record for asset_id #{row['asset_id']} successfully inserted." + rescue ActiveRecord::ActiveRecordError, StandardError => e + puts "Error inserting record for asset_id #{row['asset_id']}: #{e.message}" + end + end + end + end +end From 5c4c12909c61818eca5f1249231d7e57d5258cfc Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:44:50 +0100 Subject: [PATCH 04/61] test(add_missing_asset_audit_records_spec): Adds tests for the rake task which adds missing asset audit records --- .../add_missing_asset_audit_records_spec.rb | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 spec/lib/add_missing_asset_audit_records_spec.rb diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb new file mode 100644 index 0000000000..abdad9ef39 --- /dev/null +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +# rubocop:disable RSpec/DescribeClass +require 'rails_helper' +require 'rake' + +RSpec.describe 'asset_audit:add_missing_records' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task('asset_audit:add_missing_records') + end + + before do + Rake.application.rake_require 'tasks/add_missing_asset_audit_records' + Rake::Task.define_task(:environment) + end + + context 'when file path is not provided' do + let(:file_path) { nil } + + it 'outputs an error message and exits' do + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + end + end + + context 'when file does not exist' do + let(:file_path) { 'non_existent_file.csv' } + + it 'outputs an error message and exits' do + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + end + end + + context 'when file exists' do + let(:file_path) { 'spec/lib/asset_audit_records.csv' } + let(:csv_content) do + <<~CSV + barcode,message,created_by,created_at + SQPD-1,Destroying location,User1,2021-01-01 12:00:00 + SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 + CSV + end + + before do + allow(File).to receive(:exist?).with(file_path).and_return(true) + allow(CSV).to receive(:read).with(file_path, headers: true).and_return(CSV.parse(csv_content, headers: true)) + end + + it 'adds missing asset audit records' do + plate1 = create(:plate, barcode: 'SQPD-1') + plate2 = create(:plate, barcode: 'SQPD-2') + expect do + run_rake_task + end.to output( + /Adding missing asset audit records...\nRecord for asset_id #{plate1.id} successfully inserted.\n/ + + /Record for asset_id #{plate2.id} successfully inserted.\n/ + ).to_stdout + + expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + + expect(AssetAudit.count).to eq(2) + expect(AssetAudit.where(asset_id: plate1.id, key: 'destroy_location', +message:'Process \'Destroying location\' performed on instrument Destroying instrument').count).to eq(1) + expect(AssetAudit.where(asset_id: plate2.id, key: 'destroy_labware', +message:'Process \'Destroying labware\' performed on instrument Destroying instrument').count).to eq(1) + + end + + it 'skips records with invalid records' do + create(:plate, barcode: 'ABC123') + + expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + + expect(AssetAudit.count).to eq(1) + expect(AssetAudit.where(asset_id: plate1.id, key: 'destroy_location', +message:'Process \'Destroying location\' performed on instrument Destroying instrument').count).to eq(1) + end + + it 'handles errors when inserting records' do + create(:plate, barcode: 'ABC123') + allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') + + expect { run_rake_task }.to output(/Error inserting record for asset_id #{labware1.id}: Test error/).to_stdout + expect(AssetAudit.count).to eq(0) + + end + end +end +# rubocop:enable RSpec/DescribeClass From 70950c97c6606a6bbf7fb8be3e6b76dd1830065c Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:59:27 +0100 Subject: [PATCH 05/61] format: prettier runs --- .../add_missing_asset_audit_records.rake | 26 +++++++------ .../add_missing_asset_audit_records_spec.rb | 39 ++++++++++++------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index b20c9adb66..2acc0ddac2 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -14,24 +14,26 @@ namespace :asset_audit do ActiveRecord::Base.transaction do csv_data = CSV.read(file_path, headers: true) csv_data.each do |row| - asset = Labware.find_by_barcode(row['barcode'].strip) next if asset.nil? - key = case row['message'] - when 'Destroying location' - 'destroy_location' - when 'Destroying labware' - 'destroy_labware' - end + key = + case row['message'] + when 'Destroying location' + 'destroy_location' + when 'Destroying labware' + 'destroy_labware' + end next if key.nil? begin - AssetAudit.create!( message: "Process '#{row['message']}' performed on instrument Destroying instrument", - created_by: row['created_by'].strip, - created_at: row['created_at'].strip, - asset_id: asset.id, - key:key) + AssetAudit.create!( + message: "Process '#{row['message']}' performed on instrument Destroying instrument", + created_by: row['created_by'].strip, + created_at: row['created_at'].strip, + asset_id: asset.id, + key: key + ) puts "Record for asset_id #{row['asset_id']} successfully inserted." rescue ActiveRecord::ActiveRecordError, StandardError => e puts "Error inserting record for asset_id #{row['asset_id']}: #{e.message}" diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index abdad9ef39..37f52b1c45 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -33,13 +33,11 @@ context 'when file exists' do let(:file_path) { 'spec/lib/asset_audit_records.csv' } - let(:csv_content) do - <<~CSV + let(:csv_content) { <<~CSV } barcode,message,created_by,created_at SQPD-1,Destroying location,User1,2021-01-01 12:00:00 SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 CSV - end before do allow(File).to receive(:exist?).with(file_path).and_return(true) @@ -49,21 +47,28 @@ it 'adds missing asset audit records' do plate1 = create(:plate, barcode: 'SQPD-1') plate2 = create(:plate, barcode: 'SQPD-2') - expect do - run_rake_task - end.to output( + expect do run_rake_task end.to output( /Adding missing asset audit records...\nRecord for asset_id #{plate1.id} successfully inserted.\n/ + - /Record for asset_id #{plate2.id} successfully inserted.\n/ + /Record for asset_id #{plate2.id} successfully inserted.\n/ ).to_stdout expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout expect(AssetAudit.count).to eq(2) - expect(AssetAudit.where(asset_id: plate1.id, key: 'destroy_location', -message:'Process \'Destroying location\' performed on instrument Destroying instrument').count).to eq(1) - expect(AssetAudit.where(asset_id: plate2.id, key: 'destroy_labware', -message:'Process \'Destroying labware\' performed on instrument Destroying instrument').count).to eq(1) - + expect( + AssetAudit.where( + asset_id: plate1.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + expect( + AssetAudit.where( + asset_id: plate2.id, + key: 'destroy_labware', + message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' + ).count + ).to eq(1) end it 'skips records with invalid records' do @@ -72,8 +77,13 @@ expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout expect(AssetAudit.count).to eq(1) - expect(AssetAudit.where(asset_id: plate1.id, key: 'destroy_location', -message:'Process \'Destroying location\' performed on instrument Destroying instrument').count).to eq(1) + expect( + AssetAudit.where( + asset_id: plate1.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) end it 'handles errors when inserting records' do @@ -82,7 +92,6 @@ expect { run_rake_task }.to output(/Error inserting record for asset_id #{labware1.id}: Test error/).to_stdout expect(AssetAudit.count).to eq(0) - end end end From 5258adcbf4a452052de2d87317fbf9a29d73a17c Mon Sep 17 00:00:00 2001 From: wy1 Date: Wed, 14 Aug 2024 16:00:36 +0100 Subject: [PATCH 06/61] add wip_list method to return wip file list --- lib/record_loader/application_record_loader.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index b96a6a14e4..38d0cc5617 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -9,5 +9,13 @@ class ApplicationRecordLoader < RecordLoader::Base # Uses the standard RailsAdapter # @see https://rubydoc.info/github/sanger/record_loader/RecordLoader/Adapter adapter RecordLoader::Adapter::Rails.new + + def wip_list(directory) + wip_files = [] + Find.find(directory) do |path| + files << path if path =~ /\wip\.yml$/ + end + files + end end end From ff43c4116105da6d5be56e4bf8c82b18b0ba181d Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:43:05 +0100 Subject: [PATCH 07/61] format: prettier & rubocop updates --- .../add_missing_asset_audit_records_spec.rb | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 37f52b1c45..f4c87182f8 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true -# rubocop:disable RSpec/DescribeClass require 'rails_helper' require 'rake' -RSpec.describe 'asset_audit:add_missing_records' do +describe 'asset_audit:add_missing_records', type: :task do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task('asset_audit:add_missing_records') @@ -19,15 +18,17 @@ let(:file_path) { nil } it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + expect { run_rake_task }.to output('Please provide a valid file path').to_stdout end end context 'when file does not exist' do let(:file_path) { 'non_existent_file.csv' } + before { allow(File).to receive(:exist?).with(file_path).and_return(false) } + it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + expect { run_rake_task }.to output('Please provide a valid file path').to_stdout end end @@ -47,12 +48,14 @@ it 'adds missing asset audit records' do plate1 = create(:plate, barcode: 'SQPD-1') plate2 = create(:plate, barcode: 'SQPD-2') - expect do run_rake_task end.to output( - /Adding missing asset audit records...\nRecord for asset_id #{plate1.id} successfully inserted.\n/ + - /Record for asset_id #{plate2.id} successfully inserted.\n/ - ).to_stdout - expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + expect { run_rake_task }.to output( + / + Adding\ missing\ asset\ audit\ records...\n + Record\ for\ asset_id\ #{plate1.id}\ successfully\ inserted.\n + Record\ for\ asset_id\ #{plate2.id}\ successfully\ inserted.\n + /x + ).to_stdout expect(AssetAudit.count).to eq(2) expect( @@ -72,7 +75,7 @@ end it 'skips records with invalid records' do - create(:plate, barcode: 'ABC123') + create(:plate, barcode: 'SQPD-1') expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout @@ -87,12 +90,12 @@ end it 'handles errors when inserting records' do - create(:plate, barcode: 'ABC123') + create(:plate, barcode: 'SQPD-1') allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') expect { run_rake_task }.to output(/Error inserting record for asset_id #{labware1.id}: Test error/).to_stdout + expect(AssetAudit.count).to eq(0) end end end -# rubocop:enable RSpec/DescribeClass From 901abdd63ae3beb71e64ad3f6926289d03578cd8 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:43:53 +0100 Subject: [PATCH 08/61] Input file for the rake task to add missing records in asset_audits table --- lib/tasks/asset_audits_missing_records.csv | 112 +++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 lib/tasks/asset_audits_missing_records.csv diff --git a/lib/tasks/asset_audits_missing_records.csv b/lib/tasks/asset_audits_missing_records.csv new file mode 100644 index 0000000000..62c14289e0 --- /dev/null +++ b/lib/tasks/asset_audits_missing_records.csv @@ -0,0 +1,112 @@ +barcode,created_by,created_at,message +3981754163852,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754265679,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754264665,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754154843,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754093654,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752311712,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754165870,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752316762,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754161834,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754262876,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752229789,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754254871,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752239801,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754153839,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754160820,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754155857,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754218835,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752308767,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752309771,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754312809,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754158650,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754096686,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754313813,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754311796,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754310782,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754263651,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752241743,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752242757,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754381706,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752303717,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981753826741,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981753928797,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752301690,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981753998707,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981753586775,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754359729,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754308840,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981743460825,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754001680,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754309854,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981743456866,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752305735,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752304721,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981755006776,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981753606879,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754949654,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752306749,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754316845,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754314827,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981752307753,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754315831,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754317859,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754266683,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754002694,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754496806,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754003707,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754004711,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754000676,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +3981754363689,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, +DN693735P,aw42@sanger.ac.uk,2024-07-24 11:00:00,Destroying labware, +3981665906807,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662327780,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662328794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981664812710,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981664813724,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981673359725,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665032780,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662182792,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665033794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981657308671,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981657309685,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662110863,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662114670,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662115684,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662180774,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662181788,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981585535774,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665929875,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665930802,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665932820,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665933834,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665931816,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981652921851,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665934848,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981666122831,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981657305878,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981657306653,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981657307667,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662113666,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662123689,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662126710,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662130670,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662131684,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662111877,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662112652,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662117701,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662119729,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662121661,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662122675,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662124693,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981662125706,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665936866,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665937870,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665939669,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665938655,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665935852,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665921794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981665922807,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981666334708,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981666335712,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, +3981666336726,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location \ No newline at end of file From 97e8fa81b73d2a2b87e6763e711a29487e6694ed Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:00:19 +0100 Subject: [PATCH 09/61] update: stubs a default value for file exist method --- spec/lib/add_missing_asset_audit_records_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index f4c87182f8..c02b903f7e 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -12,6 +12,7 @@ before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' Rake::Task.define_task(:environment) + allow(File).to receive(:exist?).and_return(true) # Stub default value end context 'when file path is not provided' do @@ -41,7 +42,6 @@ CSV before do - allow(File).to receive(:exist?).with(file_path).and_return(true) allow(CSV).to receive(:read).with(file_path, headers: true).and_return(CSV.parse(csv_content, headers: true)) end From 1e2dc4583e1861fd7730e292145accf35ed0495d Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:27:06 +0100 Subject: [PATCH 10/61] Update tests --- spec/lib/add_missing_asset_audit_records_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index c02b903f7e..bb64290717 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true +# rubocop:disable RSpec/DescribeClass require 'rails_helper' require 'rake' -describe 'asset_audit:add_missing_records', type: :task do +RSpec.describe 'asset_audit:add_missing_records' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task('asset_audit:add_missing_records') @@ -99,3 +100,4 @@ end end end +# rubocop:enable RSpec/DescribeClass From 2a795360af2ef37f61dcfdb91ee2451896daa0f3 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:47:00 +0100 Subject: [PATCH 11/61] update: adds error handling for csv read --- lib/tasks/add_missing_asset_audit_records.rake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index 2acc0ddac2..8c525290ad 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -3,7 +3,7 @@ namespace :asset_audit do desc 'Add missing asset audit records' task :add_missing_records, [:file_path] => :environment do |_, args| - file_path = args[:file_path] + file_path = args[:file_path] == 'nil' ? nil : args[:file_path] if file_path.nil? || !File.exist?(file_path) puts 'Please provide a valid file path' exit @@ -12,7 +12,12 @@ namespace :asset_audit do puts 'Adding missing asset audit records...' ActiveRecord::Base.transaction do - csv_data = CSV.read(file_path, headers: true) + begin + csv_data = CSV.read(file_path, headers: true) + rescue StandardError => e + puts "Failed to read CSV file: #{e.message}" + exit 1 + end csv_data.each do |row| asset = Labware.find_by_barcode(row['barcode'].strip) next if asset.nil? @@ -34,9 +39,9 @@ namespace :asset_audit do asset_id: asset.id, key: key ) - puts "Record for asset_id #{row['asset_id']} successfully inserted." + puts "Record for asset_id #{asset.id} successfully inserted." rescue ActiveRecord::ActiveRecordError, StandardError => e - puts "Error inserting record for asset_id #{row['asset_id']}: #{e.message}" + puts "Error inserting record for asset_id #{asset.id}: #{e.message}" end end end From 381767641fc9947ed581318f16bd56beb4cd8de0 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:47:47 +0100 Subject: [PATCH 12/61] test updates --- .../add_missing_asset_audit_records_spec.rb | 56 +++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index bb64290717..a89e8d2171 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -5,9 +5,10 @@ require 'rake' RSpec.describe 'asset_audit:add_missing_records' do + let(:file_path) { 'testfile.csv' } let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task('asset_audit:add_missing_records') + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") end before do @@ -17,7 +18,10 @@ end context 'when file path is not provided' do - let(:file_path) { nil } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task('asset_audit:add_missing_records[nil]') + end it 'outputs an error message and exits' do expect { run_rake_task }.to output('Please provide a valid file path').to_stdout @@ -25,7 +29,11 @@ end context 'when file does not exist' do - let(:file_path) { 'non_existent_file.csv' } + # let (:file_path) { 'testfile.csv' } + # let(:run_rake_task) do + # Rake::Task['asset_audit:add_missing_records'].reenable + # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') + # end before { allow(File).to receive(:exist?).with(file_path).and_return(false) } @@ -34,8 +42,25 @@ end end + context 'when CSV read fails' do + # let (:file_path) { 'testfile.csv' } + # let(:run_rake_task) do + # Rake::Task['asset_audit:add_missing_records'].reenable + # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') + # end + it 'outputs an error message and exits' do + allow(CSV).to receive(:read).and_raise(StandardError, 'Test error') + + expect { run_rake_task }.to output(/Failed to read CSV file: Test error/).to_stdout + end + end + context 'when file exists' do - let(:file_path) { 'spec/lib/asset_audit_records.csv' } + # let (:file_path) { 'testfile.csv' } + # let(:run_rake_task) do + # Rake::Task['asset_audit:add_missing_records'].reenable + # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') + # end let(:csv_content) { <<~CSV } barcode,message,created_by,created_at SQPD-1,Destroying location,User1,2021-01-01 12:00:00 @@ -50,14 +75,13 @@ plate1 = create(:plate, barcode: 'SQPD-1') plate2 = create(:plate, barcode: 'SQPD-2') - expect { run_rake_task }.to output( - / - Adding\ missing\ asset\ audit\ records...\n - Record\ for\ asset_id\ #{plate1.id}\ successfully\ inserted.\n - Record\ for\ asset_id\ #{plate2.id}\ successfully\ inserted.\n - /x - ).to_stdout - + expected_output = + Regexp.new( + "Adding missing asset audit records...\\n" \ + "Record for asset_id #{plate1.id} successfully inserted.\\n" \ + "Record for asset_id #{plate2.id} successfully inserted.\\n" + ) + expect { run_rake_task }.to output(expected_output).to_stdout expect(AssetAudit.count).to eq(2) expect( AssetAudit.where( @@ -76,14 +100,14 @@ end it 'skips records with invalid records' do - create(:plate, barcode: 'SQPD-1') + plate = create(:plate, barcode: 'SQPD-1') expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout expect(AssetAudit.count).to eq(1) expect( AssetAudit.where( - asset_id: plate1.id, + asset_id: plate.id, key: 'destroy_location', message: 'Process \'Destroying location\' performed on instrument Destroying instrument' ).count @@ -91,10 +115,10 @@ end it 'handles errors when inserting records' do - create(:plate, barcode: 'SQPD-1') + plate = create(:plate, barcode: 'SQPD-1') allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') - expect { run_rake_task }.to output(/Error inserting record for asset_id #{labware1.id}: Test error/).to_stdout + expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout expect(AssetAudit.count).to eq(0) end From a56d519a6a1fbbb1f17093e8a50f9c6fdca21d7b Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:27:12 +0100 Subject: [PATCH 13/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index a89e8d2171..f691bff6c8 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -1,20 +1,13 @@ # frozen_string_literal: true -# rubocop:disable RSpec/DescribeClass require 'rails_helper' -require 'rake' -RSpec.describe 'asset_audit:add_missing_records' do +RSpec.describe 'asset_audit:add_missing_records', type: :task do let(:file_path) { 'testfile.csv' } - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") - end before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' Rake::Task.define_task(:environment) - allow(File).to receive(:exist?).and_return(true) # Stub default value end context 'when file path is not provided' do @@ -24,30 +17,29 @@ end it 'outputs an error message and exits' do - expect { run_rake_task }.to output('Please provide a valid file path').to_stdout + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout end end context 'when file does not exist' do - # let (:file_path) { 'testfile.csv' } - # let(:run_rake_task) do - # Rake::Task['asset_audit:add_missing_records'].reenable - # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') - # end + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end before { allow(File).to receive(:exist?).with(file_path).and_return(false) } it 'outputs an error message and exits' do - expect { run_rake_task }.to output('Please provide a valid file path').to_stdout + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout end end context 'when CSV read fails' do - # let (:file_path) { 'testfile.csv' } - # let(:run_rake_task) do - # Rake::Task['asset_audit:add_missing_records'].reenable - # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') - # end + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end + it 'outputs an error message and exits' do allow(CSV).to receive(:read).and_raise(StandardError, 'Test error') @@ -56,18 +48,19 @@ end context 'when file exists' do - # let (:file_path) { 'testfile.csv' } - # let(:run_rake_task) do - # Rake::Task['asset_audit:add_missing_records'].reenable - # Rake.application.invoke_task('asset_audit:add_missing_records[testfile.csv]') - # end let(:csv_content) { <<~CSV } - barcode,message,created_by,created_at - SQPD-1,Destroying location,User1,2021-01-01 12:00:00 - SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 - CSV + barcode,message,created_by,created_at + SQPD-1,Destroying location,User1,2021-01-01 12:00:00 + SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 + CSV + + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end before do + allow(File).to receive(:exist?).with(file_path).and_return(true) allow(CSV).to receive(:read).with(file_path, headers: true).and_return(CSV.parse(csv_content, headers: true)) end @@ -124,4 +117,3 @@ end end end -# rubocop:enable RSpec/DescribeClass From 37026749b5353029f243b02f4235f58bf80b5af0 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:21:10 +0100 Subject: [PATCH 14/61] Removed asset_audits missing records csv file --- lib/tasks/asset_audits_missing_records.csv | 112 --------------------- 1 file changed, 112 deletions(-) delete mode 100644 lib/tasks/asset_audits_missing_records.csv diff --git a/lib/tasks/asset_audits_missing_records.csv b/lib/tasks/asset_audits_missing_records.csv deleted file mode 100644 index 62c14289e0..0000000000 --- a/lib/tasks/asset_audits_missing_records.csv +++ /dev/null @@ -1,112 +0,0 @@ -barcode,created_by,created_at,message -3981754163852,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754265679,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754264665,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754154843,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754093654,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752311712,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754165870,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752316762,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754161834,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754262876,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752229789,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754254871,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752239801,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754153839,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754160820,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754155857,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754218835,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752308767,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752309771,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754312809,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754158650,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754096686,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754313813,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754311796,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754310782,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754263651,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752241743,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752242757,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754381706,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752303717,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981753826741,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981753928797,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752301690,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981753998707,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981753586775,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754359729,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754308840,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981743460825,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754001680,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754309854,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981743456866,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752305735,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752304721,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981755006776,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981753606879,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754949654,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752306749,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754316845,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754314827,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981752307753,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754315831,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754317859,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754266683,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754002694,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754496806,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754003707,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754004711,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754000676,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -3981754363689,aw42@sanger.ac.uk,2024-07-26 11:00:00,Destroying location, -DN693735P,aw42@sanger.ac.uk,2024-07-24 11:00:00,Destroying labware, -3981665906807,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662327780,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662328794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981664812710,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981664813724,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981673359725,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665032780,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662182792,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665033794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981657308671,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981657309685,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662110863,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662114670,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662115684,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662180774,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662181788,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981585535774,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665929875,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665930802,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665932820,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665933834,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665931816,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981652921851,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665934848,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981666122831,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981657305878,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981657306653,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981657307667,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662113666,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662123689,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662126710,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662130670,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662131684,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662111877,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662112652,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662117701,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662119729,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662121661,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662122675,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662124693,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981662125706,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665936866,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665937870,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665939669,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665938655,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665935852,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665921794,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981665922807,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981666334708,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981666335712,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location, -3981666336726,aw42@sanger.ac.uk,2024-07-18 15:30:00,Destroying location \ No newline at end of file From ab645b8500dea93034d4754a1fba52eba896dcf7 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:22:45 +0100 Subject: [PATCH 15/61] tests: added test data file for the rake task asset_audit:add_missing_records --- spec/data/asset_audits/data.csv | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spec/data/asset_audits/data.csv diff --git a/spec/data/asset_audits/data.csv b/spec/data/asset_audits/data.csv new file mode 100644 index 0000000000..1afe29c51d --- /dev/null +++ b/spec/data/asset_audits/data.csv @@ -0,0 +1,3 @@ +barcode,message,created_by,created_at +SQPD-1,Destroying location,User1,2021-01-01 12:00:00 +SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 \ No newline at end of file From 6802a2de2ef3ec18f05734fdbdc7cd6e8171049c Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:23:13 +0100 Subject: [PATCH 16/61] Update tests with a real example file --- .../add_missing_asset_audit_records_spec.rb | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index f691bff6c8..231d4c19e4 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -1,26 +1,14 @@ # frozen_string_literal: true require 'rails_helper' - RSpec.describe 'asset_audit:add_missing_records', type: :task do - let(:file_path) { 'testfile.csv' } + let(:file_path) { File.join('spec', 'data', 'asset_audits','data.csv') } before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' Rake::Task.define_task(:environment) end - context 'when file path is not provided' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task('asset_audit:add_missing_records[nil]') - end - - it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout - end - end - context 'when file does not exist' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable @@ -48,22 +36,11 @@ end context 'when file exists' do - let(:csv_content) { <<~CSV } - barcode,message,created_by,created_at - SQPD-1,Destroying location,User1,2021-01-01 12:00:00 - SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 - CSV - let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") end - before do - allow(File).to receive(:exist?).with(file_path).and_return(true) - allow(CSV).to receive(:read).with(file_path, headers: true).and_return(CSV.parse(csv_content, headers: true)) - end - it 'adds missing asset audit records' do plate1 = create(:plate, barcode: 'SQPD-1') plate2 = create(:plate, barcode: 'SQPD-2') From e4e7297104bf0ad2c136f7e90a0adb62c28a2c33 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:28:08 +0100 Subject: [PATCH 17/61] Prettier updates --- spec/lib/add_missing_asset_audit_records_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 231d4c19e4..335889c48f 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe 'asset_audit:add_missing_records', type: :task do - let(:file_path) { File.join('spec', 'data', 'asset_audits','data.csv') } + let(:file_path) { File.join('spec', 'data', 'asset_audits', 'data.csv') } before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' From c10ce2a030ff0c59ddfd3f158e0d784f5d364500 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:52:51 +0100 Subject: [PATCH 18/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 335889c48f..1748788a27 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -9,32 +9,6 @@ Rake::Task.define_task(:environment) end - context 'when file does not exist' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") - end - - before { allow(File).to receive(:exist?).with(file_path).and_return(false) } - - it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout - end - end - - context 'when CSV read fails' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") - end - - it 'outputs an error message and exits' do - allow(CSV).to receive(:read).and_raise(StandardError, 'Test error') - - expect { run_rake_task }.to output(/Failed to read CSV file: Test error/).to_stdout - end - end - context 'when file exists' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable From f3718e2fa936b2bfdbf908adc486a3b4aa83a248 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:03:38 +0100 Subject: [PATCH 19/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 1748788a27..9974a0e62d 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -7,64 +7,64 @@ before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' Rake::Task.define_task(:environment) + allow(File).to receive(:exist?).and_return(true) # Stub default value end - context 'when file exists' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") - end - - it 'adds missing asset audit records' do - plate1 = create(:plate, barcode: 'SQPD-1') - plate2 = create(:plate, barcode: 'SQPD-2') + describe 'test1' do + context 'when file exists' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end - expected_output = - Regexp.new( - "Adding missing asset audit records...\\n" \ - "Record for asset_id #{plate1.id} successfully inserted.\\n" \ - "Record for asset_id #{plate2.id} successfully inserted.\\n" - ) - expect { run_rake_task }.to output(expected_output).to_stdout - expect(AssetAudit.count).to eq(2) - expect( - AssetAudit.where( - asset_id: plate1.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - expect( - AssetAudit.where( - asset_id: plate2.id, - key: 'destroy_labware', - message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - end + it 'adds missing asset audit records' do + plate1 = create(:plate, barcode: 'SQPD-1') + plate2 = create(:plate, barcode: 'SQPD-2') - it 'skips records with invalid records' do - plate = create(:plate, barcode: 'SQPD-1') + expected_output = + Regexp.new( + "Adding missing asset audit records...\\n" \ + "Record for asset_id #{plate1.id} successfully inserted.\\n" \ + "Record for asset_id #{plate2.id} successfully inserted.\\n" + ) + expect { run_rake_task }.to output(expected_output).to_stdout + expect( + AssetAudit.where( + asset_id: plate1.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + expect( + AssetAudit.where( + asset_id: plate2.id, + key: 'destroy_labware', + message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + end - expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + it 'skips records with invalid records' do + plate = create(:plate, barcode: 'SQPD-1') - expect(AssetAudit.count).to eq(1) - expect( - AssetAudit.where( - asset_id: plate.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - end + expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + expect( + AssetAudit.where( + asset_id: plate.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + end - it 'handles errors when inserting records' do - plate = create(:plate, barcode: 'SQPD-1') - allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') + it 'handles errors when inserting records' do + plate = create(:plate, barcode: 'SQPD-1') + allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') - expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout + expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout - expect(AssetAudit.count).to eq(0) + expect(AssetAudit.count).to eq(0) + end end end end From 89d07ca7595c1fbe96a26a2d4f129f7ebf399c2c Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:11:41 +0100 Subject: [PATCH 20/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 94 +++++++++---------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 9974a0e62d..9d40ba875c 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -10,61 +10,57 @@ allow(File).to receive(:exist?).and_return(true) # Stub default value end - describe 'test1' do - context 'when file exists' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") - end - - it 'adds missing asset audit records' do - plate1 = create(:plate, barcode: 'SQPD-1') - plate2 = create(:plate, barcode: 'SQPD-2') + context 'when file exists' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end - expected_output = - Regexp.new( - "Adding missing asset audit records...\\n" \ - "Record for asset_id #{plate1.id} successfully inserted.\\n" \ - "Record for asset_id #{plate2.id} successfully inserted.\\n" - ) - expect { run_rake_task }.to output(expected_output).to_stdout - expect( - AssetAudit.where( - asset_id: plate1.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - expect( - AssetAudit.where( - asset_id: plate2.id, - key: 'destroy_labware', - message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - end + it 'adds missing asset audit records' do + plate1 = create(:plate, barcode: 'SQPD-1') + plate2 = create(:plate, barcode: 'SQPD-2') - it 'skips records with invalid records' do - plate = create(:plate, barcode: 'SQPD-1') + expected_output = + Regexp.new( + "Adding missing asset audit records...\\n" \ + "Record for asset_id #{plate1.id} successfully inserted.\\n" \ + "Record for asset_id #{plate2.id} successfully inserted.\\n" + ) + expect { run_rake_task }.to output(expected_output).to_stdout + expect( + AssetAudit.where( + asset_id: plate1.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + expect( + AssetAudit.where( + asset_id: plate2.id, + key: 'destroy_labware', + message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + end - expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout - expect( - AssetAudit.where( - asset_id: plate.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) - end + it 'skips records with invalid records' do + plate = create(:plate, barcode: 'SQPD-1') - it 'handles errors when inserting records' do - plate = create(:plate, barcode: 'SQPD-1') - allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') + expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout + expect( + AssetAudit.where( + asset_id: plate.id, + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ).count + ).to eq(1) + end - expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout + it 'handles errors when inserting records' do + plate = create(:plate, barcode: 'SQPD-1') + allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') - expect(AssetAudit.count).to eq(0) - end + expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout end end end From b51eafb1dded5d434e5433412b8e00d881d2c658 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:17:49 +0100 Subject: [PATCH 21/61] Update add_missing_asset_audit_records_spec.rb --- spec/lib/add_missing_asset_audit_records_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 9d40ba875c..4dd1c313a8 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -32,15 +32,15 @@ asset_id: plate1.id, key: 'destroy_location', message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) + ) + ).to exist expect( AssetAudit.where( asset_id: plate2.id, key: 'destroy_labware', message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ).count - ).to eq(1) + ) + ).to exist end it 'skips records with invalid records' do @@ -52,8 +52,8 @@ asset_id: plate.id, key: 'destroy_location', message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ).count - ).to eq(1) + ) + ).to exist end it 'handles errors when inserting records' do From 6793de030b7a2f5d9921007b4e024998576554e9 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:34:47 +0100 Subject: [PATCH 22/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 4dd1c313a8..e531bd2a0a 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -10,7 +10,7 @@ allow(File).to receive(:exist?).and_return(true) # Stub default value end - context 'when file exists' do + describe 'file exists' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") @@ -45,15 +45,21 @@ it 'skips records with invalid records' do plate = create(:plate, barcode: 'SQPD-1') + expected_count = + AssetAudit.where( + asset_id: plate.id, + key: 'destroy_labware', + message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' + ).count expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout - expect( + count = AssetAudit.where( asset_id: plate.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ) - ).to exist + key: 'destroy_labware', + message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' + ).count + expect(count).to eq(expected_count) end it 'handles errors when inserting records' do @@ -63,4 +69,17 @@ expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout end end + + describe 'file does not exist' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task('asset_audit:add_missing_records[nil]') + end + + context 'when the file does not exist' do + it 'outputs an error message and exits' do + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + end + end + end end From a1e1a34f8025cbaec179f6fb0ff79016a3c47088 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:44:11 +0100 Subject: [PATCH 23/61] Update add_missing_asset_audit_records_spec.rb --- .../add_missing_asset_audit_records_spec.rb | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index e531bd2a0a..4dd1c313a8 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -10,7 +10,7 @@ allow(File).to receive(:exist?).and_return(true) # Stub default value end - describe 'file exists' do + context 'when file exists' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") @@ -45,21 +45,15 @@ it 'skips records with invalid records' do plate = create(:plate, barcode: 'SQPD-1') - expected_count = - AssetAudit.where( - asset_id: plate.id, - key: 'destroy_labware', - message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ).count expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout - count = + expect( AssetAudit.where( asset_id: plate.id, - key: 'destroy_labware', - message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ).count - expect(count).to eq(expected_count) + key: 'destroy_location', + message: 'Process \'Destroying location\' performed on instrument Destroying instrument' + ) + ).to exist end it 'handles errors when inserting records' do @@ -69,17 +63,4 @@ expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout end end - - describe 'file does not exist' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task('asset_audit:add_missing_records[nil]') - end - - context 'when the file does not exist' do - it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout - end - end - end end From b3a020cf9bec3dd6724eec83ff05d04e14c52c8a Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:00:10 +0100 Subject: [PATCH 24/61] update: return from rake task using next --- lib/tasks/add_missing_asset_audit_records.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index 8c525290ad..80f7ee7fd5 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -6,7 +6,7 @@ namespace :asset_audit do file_path = args[:file_path] == 'nil' ? nil : args[:file_path] if file_path.nil? || !File.exist?(file_path) puts 'Please provide a valid file path' - exit + next end puts 'Adding missing asset audit records...' @@ -16,7 +16,7 @@ namespace :asset_audit do csv_data = CSV.read(file_path, headers: true) rescue StandardError => e puts "Failed to read CSV file: #{e.message}" - exit 1 + next end csv_data.each do |row| asset = Labware.find_by_barcode(row['barcode'].strip) From 9a9d548dc755c7b438efdf3b7f24dbed239d903d Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:00:27 +0100 Subject: [PATCH 25/61] tests: update --- .../add_missing_asset_audit_records_spec.rb | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 4dd1c313a8..d5ad11ac0c 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -63,4 +63,43 @@ expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout end end + + describe 'file does not exist' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task('asset_audit:add_missing_records[nil]') + end + + context 'when the file does not exist' do + it 'outputs an error message and exits' do + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + end + end + + context 'when file does not exist' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end + + before { allow(File).to receive(:exist?).with(file_path).and_return(false) } + + it 'outputs an error message and exits' do + expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + end + end + + context 'when CSV read fails' do + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end + + it 'outputs an error message and exits' do + allow(CSV).to receive(:read).and_raise(StandardError, 'Test error') + + expect { run_rake_task }.to output(/Failed to read CSV file: Test error/).to_stdout + end + end + end end From 7fa451f63064313b48a15d78d30a059d1d0b6749 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:23:01 +0100 Subject: [PATCH 26/61] Update add_missing_asset_audit_records_spec.rb --- spec/lib/add_missing_asset_audit_records_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index d5ad11ac0c..c32e20200e 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -72,7 +72,7 @@ context 'when the file does not exist' do it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout end end @@ -85,7 +85,7 @@ before { allow(File).to receive(:exist?).with(file_path).and_return(false) } it 'outputs an error message and exits' do - expect { run_rake_task }.to output("Please provide a valid file path\n").to_stdout + expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout end end From 56378866bee4ae9555c0de2a70ae61ad08967f7b Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:22:10 +0100 Subject: [PATCH 27/61] refactor(add_missing_asset_audit_records): Chnages for csv processing, validation and rollback - Separates csv processing and validation for creating asset audit record data - Rollback on errors while inserting data - Adds documentation --- .../add_missing_asset_audit_records.rake | 108 +++++++++++++----- 1 file changed, 78 insertions(+), 30 deletions(-) diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index 80f7ee7fd5..d6cba5dec4 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -1,49 +1,97 @@ # frozen_string_literal: true +# Rails task to add missing asset audit records from a CSV file namespace :asset_audit do + # This rake task is used to add missing asset audit records from a CSV file. + # If there are any errors in the CSV file, no records will be inserted. + # Usage: rails asset_audit:add_missing_records['/path/to/file.csv'] + # The CSV file should have the following headers: + # barcode, message, created_by, created_at + # The message column should have one of the following values: + # 'Destroying location', 'Destroying labware' + desc 'Add missing asset audit records' task :add_missing_records, [:file_path] => :environment do |_, args| + required_csv_headers = %w[barcode message created_by created_at] + + # Check if the file path is provided and valid file_path = args[:file_path] == 'nil' ? nil : args[:file_path] if file_path.nil? || !File.exist?(file_path) puts 'Please provide a valid file path' next end - puts 'Adding missing asset audit records...' + # Read the CSV file and validate the headers + begin + csv_data = CSV.read(file_path, headers: true) + rescue StandardError => e + puts "Failed to read CSV file: #{e.message}" + next + end - ActiveRecord::Base.transaction do - begin - csv_data = CSV.read(file_path, headers: true) - rescue StandardError => e - puts "Failed to read CSV file: #{e.message}" + unless csv_data.headers.length == required_csv_headers.length + puts 'Failed to read CSV file: Invalid number of header columns' + next + end + + # Process the CSV data and create asset audit records data array to insert + asset_audit_data = [] + csv_data.each do |row| + missing_columns = required_csv_headers.select { |header| row[header].nil? } + + # Check if any of the required columns are missing + unless missing_columns.empty? + puts 'Failed to read CSV file: Missing columns' + next + end + + # Find the asset by barcode + asset = Labware.find_by_barcode(row['barcode'].strip) + if asset.nil? + puts "Asset with barcode #{row['barcode']} not found." next end - csv_data.each do |row| - asset = Labware.find_by_barcode(row['barcode'].strip) - next if asset.nil? - - key = - case row['message'] - when 'Destroying location' - 'destroy_location' - when 'Destroying labware' - 'destroy_labware' - end - next if key.nil? - - begin - AssetAudit.create!( - message: "Process '#{row['message']}' performed on instrument Destroying instrument", - created_by: row['created_by'].strip, - created_at: row['created_at'].strip, - asset_id: asset.id, - key: key - ) - puts "Record for asset_id #{asset.id} successfully inserted." - rescue ActiveRecord::ActiveRecordError, StandardError => e - puts "Error inserting record for asset_id #{asset.id}: #{e.message}" + + # Check if the message is valid + key = + case row['message'] + when 'Destroying location' + 'destroy_location' + when 'Destroying labware' + 'destroy_labware' end + + if key.nil? + puts "Invalid message for asset with barcode #{row['barcode']}." + next + end + + # Create the asset audit record data + data = { + asset_id: asset.id, + created_by: row['created_by'], + created_at: row['created_at'], + message: "Process '#{row['message']}' performed on instrument Destroying instrument", + key: key + } + asset_audit_data << data + end + + # Insert the asset audit records + ActiveRecord::Base.transaction do + asset_audit_data.each do |data| + AssetAudit.create!( + message: data[:message], + created_by: data[:created_by], + created_at: data[:created_at], + asset_id: data[:asset_id], + key: data[:key] + ) end + puts 'All records successfully inserted.' + rescue ActiveRecord::ActiveRecordError => e + puts "Failed to insert records: #{e.message}" + raise ActiveRecord::Rollback end end end From 2183551a8aa616858faf600baabdb219e0e4f3d4 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:22:58 +0100 Subject: [PATCH 28/61] tests : modified tests to use of fixture files --- .../add_missing_asset_audit_records_spec.rb | 153 +++++++++++------- 1 file changed, 92 insertions(+), 61 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index c32e20200e..0e1b099b77 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -1,104 +1,135 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe 'asset_audit:add_missing_records', type: :task do - let(:file_path) { File.join('spec', 'data', 'asset_audits', 'data.csv') } +RSpec.describe 'asset_audit:add_missing_records', type: :task do before do Rake.application.rake_require 'tasks/add_missing_asset_audit_records' Rake::Task.define_task(:environment) - allow(File).to receive(:exist?).and_return(true) # Stub default value end - context 'when file exists' do + context 'when an invalid file path is given' do let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + Rake.application.invoke_task('asset_audit:add_missing_records[nil]') end - it 'adds missing asset audit records' do - plate1 = create(:plate, barcode: 'SQPD-1') - plate2 = create(:plate, barcode: 'SQPD-2') - - expected_output = - Regexp.new( - "Adding missing asset audit records...\\n" \ - "Record for asset_id #{plate1.id} successfully inserted.\\n" \ - "Record for asset_id #{plate2.id} successfully inserted.\\n" - ) - expect { run_rake_task }.to output(expected_output).to_stdout - expect( - AssetAudit.where( - asset_id: plate1.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ) - ).to exist - expect( - AssetAudit.where( - asset_id: plate2.id, - key: 'destroy_labware', - message: 'Process \'Destroying labware\' performed on instrument Destroying instrument' - ) - ).to exist + it 'outputs an error message and returns' do + expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout end + end + + describe 'invalid csv file' do + context 'when csv has a bad format' do + let(:file_path) { 'spec/data/asset_audits/bad_format.csv' } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end - it 'skips records with invalid records' do - plate = create(:plate, barcode: 'SQPD-1') - - expect { run_rake_task }.to output(/Adding missing asset audit records.../).to_stdout - expect( - AssetAudit.where( - asset_id: plate.id, - key: 'destroy_location', - message: 'Process \'Destroying location\' performed on instrument Destroying instrument' - ) - ).to exist + it 'outputs an error message and return' do + expect { run_rake_task }.to output(/Failed to read CSV file/).to_stdout + end end - it 'handles errors when inserting records' do - plate = create(:plate, barcode: 'SQPD-1') - allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') + context 'when csv columns are mising' do + let(:file_path) { 'spec/data/asset_audits/missing_column.csv' } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end - expect { run_rake_task }.to output(/Error inserting record for asset_id #{plate.id}: Test error/).to_stdout + it 'outputs an error message and return' do + expect { run_rake_task }.to output(/Failed to read CSV file: Missing columns/).to_stdout + end end - end - describe 'file does not exist' do - let(:run_rake_task) do - Rake::Task['asset_audit:add_missing_records'].reenable - Rake.application.invoke_task('asset_audit:add_missing_records[nil]') + context 'when csv with no header given' do + let(:file_path) { 'spec/data/asset_audits/missing_header.csv' } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end + + it 'outputs an error message and return' do + expect { run_rake_task }.to output(/Failed to read CSV file: Invalid number of header columns/).to_stdout + end end + end + + describe 'valid csv file' do + context 'when asset with barcode is not found' do + let(:file_path) { 'spec/data/asset_audits/valid_data.csv' } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end + + it 'does not add records if there is any invalid data' do + create(:plate, barcode: 'SQPD-1') - context 'when the file does not exist' do - it 'outputs an error message and exits' do - expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout + expect { run_rake_task }.to output(/Asset with barcode SQPD-2 not found./).to_stdout end end - context 'when file does not exist' do + context 'when message column is invalid' do + let(:file_path) { 'spec/data/asset_audits/invalid_message.csv' } let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") end - before { allow(File).to receive(:exist?).with(file_path).and_return(false) } + it 'does not add records if there is any invalid data' do + create(:plate, barcode: 'SQPD-1') + + expect { run_rake_task }.to output(/Invalid message for asset with barcode SQPD-1/).to_stdout + end + end + + context 'when all data is good' do + let(:file_path) { 'spec/data/asset_audits/valid_data.csv' } + let(:run_rake_task) do + Rake::Task['asset_audit:add_missing_records'].reenable + Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") + end - it 'outputs an error message and exits' do - expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout + it 'adds missing asset audit records' do + plate1 = create(:plate, barcode: 'SQPD-1') + plate2 = create(:plate, barcode: 'SQPD-2') + + expect { run_rake_task }.to output(/All records successfully inserted./).to_stdout + + expect( + AssetAudit.where( + asset_id: plate1.id, + key: 'destroy_location', + message: "Process 'Destroying location' performed on instrument Destroying instrument" + ) + ).to exist + + expect( + AssetAudit.where( + asset_id: plate2.id, + key: 'destroy_labware', + message: "Process 'Destroying labware' performed on instrument Destroying instrument" + ) + ).to exist end end - context 'when CSV read fails' do + context 'when there is a failed transaction' do + let(:file_path) { 'spec/data/asset_audits/valid_data.csv' } let(:run_rake_task) do Rake::Task['asset_audit:add_missing_records'].reenable Rake.application.invoke_task("asset_audit:add_missing_records[#{file_path}]") end - it 'outputs an error message and exits' do - allow(CSV).to receive(:read).and_raise(StandardError, 'Test error') + it 'rolls back transaction when there is an error in inserting records' do + create(:plate, barcode: 'SQPD-1') + create(:plate, barcode: 'SQPD-2') + allow(AssetAudit).to receive(:create!).and_raise(ActiveRecord::ActiveRecordError, 'Test error') - expect { run_rake_task }.to output(/Failed to read CSV file: Test error/).to_stdout + expect { run_rake_task }.to output(/Failed to insert records: Test error/).to_stdout end end end From 5a79ef7adc5cbfca385b67d2ed32bbbad773522d Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:24:36 +0100 Subject: [PATCH 29/61] test: adds fixture files --- spec/data/asset_audits/bad_format.csv | 2 ++ spec/data/asset_audits/invalid_message.csv | 2 ++ spec/data/asset_audits/missing_column.csv | 2 ++ spec/data/asset_audits/missing_header.csv | 2 ++ spec/data/asset_audits/{data.csv => valid_data.csv} | 0 5 files changed, 8 insertions(+) create mode 100644 spec/data/asset_audits/bad_format.csv create mode 100644 spec/data/asset_audits/invalid_message.csv create mode 100644 spec/data/asset_audits/missing_column.csv create mode 100644 spec/data/asset_audits/missing_header.csv rename spec/data/asset_audits/{data.csv => valid_data.csv} (100%) diff --git a/spec/data/asset_audits/bad_format.csv b/spec/data/asset_audits/bad_format.csv new file mode 100644 index 0000000000..56a619cb61 --- /dev/null +++ b/spec/data/asset_audits/bad_format.csv @@ -0,0 +1,2 @@ +barcode,message,created_by,created_at +SQPD-9002;"Destroying location;User1,2021-01-01 12:00:00 \ No newline at end of file diff --git a/spec/data/asset_audits/invalid_message.csv b/spec/data/asset_audits/invalid_message.csv new file mode 100644 index 0000000000..909fdf8356 --- /dev/null +++ b/spec/data/asset_audits/invalid_message.csv @@ -0,0 +1,2 @@ +barcode,message,created_by,created_at +SQPD-1,Destroying test,User1,2021-01-01 12:00:00 \ No newline at end of file diff --git a/spec/data/asset_audits/missing_column.csv b/spec/data/asset_audits/missing_column.csv new file mode 100644 index 0000000000..2d92e7b611 --- /dev/null +++ b/spec/data/asset_audits/missing_column.csv @@ -0,0 +1,2 @@ +barcode,message,created_by,created_at +SQPD-1,Destroying location,2021-01-01 12:00:00 \ No newline at end of file diff --git a/spec/data/asset_audits/missing_header.csv b/spec/data/asset_audits/missing_header.csv new file mode 100644 index 0000000000..9e394c24a4 --- /dev/null +++ b/spec/data/asset_audits/missing_header.csv @@ -0,0 +1,2 @@ +barcode,created_by,created_at +SQPD-1,Destroying location,2021-01-01 12:00:00 \ No newline at end of file diff --git a/spec/data/asset_audits/data.csv b/spec/data/asset_audits/valid_data.csv similarity index 100% rename from spec/data/asset_audits/data.csv rename to spec/data/asset_audits/valid_data.csv From fa083b071fc8ae16236bc85da63e2d6aab7fc7fb Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:39:34 +0100 Subject: [PATCH 30/61] fixture file updates --- spec/data/asset_audits/bad_format.csv | 2 +- spec/data/asset_audits/invalid_message.csv | 2 +- spec/data/asset_audits/missing_column.csv | 2 +- spec/data/asset_audits/missing_header.csv | 2 +- spec/data/asset_audits/valid_data.csv | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/data/asset_audits/bad_format.csv b/spec/data/asset_audits/bad_format.csv index 56a619cb61..6570e00bf3 100644 --- a/spec/data/asset_audits/bad_format.csv +++ b/spec/data/asset_audits/bad_format.csv @@ -1,2 +1,2 @@ barcode,message,created_by,created_at -SQPD-9002;"Destroying location;User1,2021-01-01 12:00:00 \ No newline at end of file +SQPD-9002;"Destroying location;User1,2021-01-01 12:00:00 diff --git a/spec/data/asset_audits/invalid_message.csv b/spec/data/asset_audits/invalid_message.csv index 909fdf8356..0e169ba528 100644 --- a/spec/data/asset_audits/invalid_message.csv +++ b/spec/data/asset_audits/invalid_message.csv @@ -1,2 +1,2 @@ barcode,message,created_by,created_at -SQPD-1,Destroying test,User1,2021-01-01 12:00:00 \ No newline at end of file +SQPD-1,Destroying test,User1,2021-01-01 12:00:00 diff --git a/spec/data/asset_audits/missing_column.csv b/spec/data/asset_audits/missing_column.csv index 2d92e7b611..efa5b5b9d1 100644 --- a/spec/data/asset_audits/missing_column.csv +++ b/spec/data/asset_audits/missing_column.csv @@ -1,2 +1,2 @@ barcode,message,created_by,created_at -SQPD-1,Destroying location,2021-01-01 12:00:00 \ No newline at end of file +SQPD-1,Destroying location,2021-01-01 12:00:00 diff --git a/spec/data/asset_audits/missing_header.csv b/spec/data/asset_audits/missing_header.csv index 9e394c24a4..95437983ce 100644 --- a/spec/data/asset_audits/missing_header.csv +++ b/spec/data/asset_audits/missing_header.csv @@ -1,2 +1,2 @@ barcode,created_by,created_at -SQPD-1,Destroying location,2021-01-01 12:00:00 \ No newline at end of file +SQPD-1,Destroying location,2021-01-01 12:00:00 diff --git a/spec/data/asset_audits/valid_data.csv b/spec/data/asset_audits/valid_data.csv index 1afe29c51d..e1b3a4f7a7 100644 --- a/spec/data/asset_audits/valid_data.csv +++ b/spec/data/asset_audits/valid_data.csv @@ -1,3 +1,3 @@ barcode,message,created_by,created_at SQPD-1,Destroying location,User1,2021-01-01 12:00:00 -SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 \ No newline at end of file +SQPD-2,Destroying labware,User2,2021-01-02 12:00:00 From e0f2dc1bf1f72d7b9d49a6a85a0fb4cba884dbe8 Mon Sep 17 00:00:00 2001 From: yoldas Date: Mon, 19 Aug 2024 13:41:53 +0100 Subject: [PATCH 31/61] Add info about generating database ERD --- README.md | 78 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 4630426d0e..0042d3e245 100644 --- a/README.md +++ b/README.md @@ -27,38 +27,42 @@ a organisation of 900 people. -- [Documentation](#documentation) -- [Requirements](#requirements) -- [Getting started (using Docker)](#getting-started-using-docker) -- [Getting started (using native installation)](#getting-started-using-native-installation) - - [Installing ruby](#installing-ruby) - - [rbenv](#rbenv) - - [Automatic Sequencescape setup](#automatic-sequencescape-setup) - - [Manual Sequencescape setup](#manual-sequencescape-setup) - - [Installing gems](#installing-gems) - - [Adjusting config](#adjusting-config) - - [Default setup](#default-setup) - - [Starting rails](#starting-rails) - - [Delayed job](#delayed-job) - - [Message broker](#message-broker) -- [Testing](#testing) -- [Linting and formatting](#linting-and-formatting) -- [Rake tasks](#rake-tasks) -- [Supporting applications](#supporting-applications) - - [Barcode printing](#barcode-printing) - - [Plate barcode service](#plate-barcode-service) - - [Data warehousing](#data-warehousing) -- [Miscellaneous](#miscellaneous) - - [Lefthook](#lefthook) - - [Ruby warnings and rake 11](#ruby-warnings-and-rake-11) - - [NPG - Illumina tracking software](#npg---illumina-tracking-software) - - [Troubleshooting](#troubleshooting) - - [MySQL errors when installing](#mysql-errors-when-installing) - - [Installing on Apple Silicon (M1)](#installing-on-apple-silicon-m1) - - [API V2 Authentication](#api-v2-authentication) - - [Publishing AMQP Messages](#publishing-amqp-messages) - - [Updating the table of contents](#updating-the-table-of-contents) - - [CI](#ci) +- [ Sequencescape](#-sequencescape) + - [Contents](#contents) + - [Documentation](#documentation) + - [Linting](#linting) + - [Requirements](#requirements) + - [Getting started (using Docker)](#getting-started-using-docker) + - [Getting started (using native installation)](#getting-started-using-native-installation) + - [Installing ruby](#installing-ruby) + - [rbenv](#rbenv) + - [Automatic Sequencescape setup](#automatic-sequencescape-setup) + - [Manual Sequencescape setup](#manual-sequencescape-setup) + - [Installing gems](#installing-gems) + - [Adjusting config](#adjusting-config) + - [Default setup](#default-setup) + - [Starting rails](#starting-rails) + - [Delayed job](#delayed-job) + - [Message broker](#message-broker) + - [Testing](#testing) + - [Linting and formatting](#linting-and-formatting) + - [Rake tasks](#rake-tasks) + - [Supporting applications](#supporting-applications) + - [Barcode printing](#barcode-printing) + - [Plate barcode service](#plate-barcode-service) + - [Data warehousing](#data-warehousing) + - [Miscellaneous](#miscellaneous) + - [Lefthook](#lefthook) + - [Ruby warnings and rake 11](#ruby-warnings-and-rake-11) + - [NPG - Illumina tracking software](#npg---illumina-tracking-software) + - [Troubleshooting](#troubleshooting) + - [MySQL errors when installing](#mysql-errors-when-installing) + - [Installing on Apple Silicon (M1)](#installing-on-apple-silicon-m1) + - [API V2 Authentication](#api-v2-authentication) + - [Publishing AMQP Messages](#publishing-amqp-messages) + - [Updating the table of contents](#updating-the-table-of-contents) + - [CI](#ci) + - [ERD](#erd) @@ -454,3 +458,13 @@ npx markdown-toc -i README.md --bullets "-" The GH actions builds use the Knapsack-pro gem to reduce build time by parallelizing the RSpec and Cucumber tests. There is no need to regenerate the knapsack_rspec_report.json file, Knapsack Pro will dynamically allocate tests to ensure tests finish as close together as possible. Copyright (c) 2007, 2010-2021 Genome Research Ltd. + +### ERD + +You can create a database entity relationship diagram and view the output: + +``` +bundle exec erd +open erd.pdf +``` +The command uses the [rails-erd](https://github.com/voormedia/rails-erd) gem. \ No newline at end of file From 995e39958c3801e36fd88a75a78b0ab609732f5d Mon Sep 17 00:00:00 2001 From: yoldas Date: Mon, 19 Aug 2024 13:43:49 +0100 Subject: [PATCH 32/61] Fix minor typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0042d3e245..989a9676c0 100644 --- a/README.md +++ b/README.md @@ -461,7 +461,7 @@ Copyright (c) 2007, 2010-2021 Genome Research Ltd. ### ERD -You can create a database entity relationship diagram and view the output: +You can create a database entity relationship diagram and view the output: ``` bundle exec erd From 2c75b8215cafba69d2a748bbd4b5679accd7d9ec Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Mon, 19 Aug 2024 14:06:27 +0100 Subject: [PATCH 33/61] [skip ci] docs: Update readme with details on documentation process --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4630426d0e..99ce2c4ba2 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ You can then access the Sequencescape documentation through: [http://localhost:8 Yard will also try and document the installed gems: [http://localhost:8808/docs](http://localhost:8808/docs) +The Yard documentation is also hosted in [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). Each `master` merge (i.e., release) would trigger a CI action (`.github/workflows/generate_pages.yml`) that deploy the Yard docs to GitHub Pages. This workflow can also be triggered via `workflow_dispatch` event which means it could be triggered manually through the "Deploy Yard to GitHub Pages" action in Actions tab in sequencescape repository. + ### Linting Yard-Junk is used to check for missing or incorrect documentation. To run the checks: From 1e425120d22e1a8c58aa83e9c81fba3f56c74e9c Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:18:10 +0100 Subject: [PATCH 34/61] update: returns from rake task in case of any csv validation failures --- .../add_missing_asset_audit_records.rake | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/tasks/add_missing_asset_audit_records.rake b/lib/tasks/add_missing_asset_audit_records.rake index d6cba5dec4..eef55f14c4 100644 --- a/lib/tasks/add_missing_asset_audit_records.rake +++ b/lib/tasks/add_missing_asset_audit_records.rake @@ -16,22 +16,17 @@ namespace :asset_audit do # Check if the file path is provided and valid file_path = args[:file_path] == 'nil' ? nil : args[:file_path] - if file_path.nil? || !File.exist?(file_path) - puts 'Please provide a valid file path' - next - end + raise 'Please provide a valid file path' if file_path.nil? || !File.exist?(file_path) # Read the CSV file and validate the headers begin csv_data = CSV.read(file_path, headers: true) rescue StandardError => e - puts "Failed to read CSV file: #{e.message}" - next + raise "Failed to read CSV file: #{e.message}" end unless csv_data.headers.length == required_csv_headers.length - puts 'Failed to read CSV file: Invalid number of header columns' - next + raise 'Failed to read CSV file: Invalid number of header columns.' end # Process the CSV data and create asset audit records data array to insert @@ -40,17 +35,11 @@ namespace :asset_audit do missing_columns = required_csv_headers.select { |header| row[header].nil? } # Check if any of the required columns are missing - unless missing_columns.empty? - puts 'Failed to read CSV file: Missing columns' - next - end + raise 'Failed to read CSV file: Missing columns.' unless missing_columns.empty? # Find the asset by barcode asset = Labware.find_by_barcode(row['barcode'].strip) - if asset.nil? - puts "Asset with barcode #{row['barcode']} not found." - next - end + raise "Asset with barcode #{row['barcode']} not found." if asset.nil? # Check if the message is valid key = @@ -61,10 +50,7 @@ namespace :asset_audit do 'destroy_labware' end - if key.nil? - puts "Invalid message for asset with barcode #{row['barcode']}." - next - end + raise "Invalid message for asset with barcode #{row['barcode']}." if key.nil? # Create the asset audit record data data = { From 71bae4ceb2585896b296f35f0a53a475312b0a64 Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:18:32 +0100 Subject: [PATCH 35/61] test updates --- spec/lib/add_missing_asset_audit_records_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 0e1b099b77..1e3b1c1b9a 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -15,7 +15,7 @@ end it 'outputs an error message and returns' do - expect { run_rake_task }.to output(/Please provide a valid file path/).to_stdout + expect { run_rake_task }.to raise_error(RuntimeError,/Please provide a valid file path/) end end @@ -28,7 +28,7 @@ end it 'outputs an error message and return' do - expect { run_rake_task }.to output(/Failed to read CSV file/).to_stdout + expect { run_rake_task }.to raise_error(RuntimeError,/Failed to read CSV file/) end end @@ -40,7 +40,7 @@ end it 'outputs an error message and return' do - expect { run_rake_task }.to output(/Failed to read CSV file: Missing columns/).to_stdout + expect { run_rake_task }.to raise_error(RuntimeError, 'Failed to read CSV file: Missing columns.') end end @@ -52,7 +52,7 @@ end it 'outputs an error message and return' do - expect { run_rake_task }.to output(/Failed to read CSV file: Invalid number of header columns/).to_stdout + expect { run_rake_task }.to raise_error(/Failed to read CSV file: Invalid number of header columns./) end end end @@ -68,7 +68,7 @@ it 'does not add records if there is any invalid data' do create(:plate, barcode: 'SQPD-1') - expect { run_rake_task }.to output(/Asset with barcode SQPD-2 not found./).to_stdout + expect { run_rake_task }.to raise_error(RuntimeError, 'Asset with barcode SQPD-2 not found.') end end @@ -82,7 +82,7 @@ it 'does not add records if there is any invalid data' do create(:plate, barcode: 'SQPD-1') - expect { run_rake_task }.to output(/Invalid message for asset with barcode SQPD-1/).to_stdout + expect { run_rake_task }.to raise_error(RuntimeError, 'Invalid message for asset with barcode SQPD-1.') end end From 80f2a1cbd3ec0e52fcecf7c662c691dcc49b145b Mon Sep 17 00:00:00 2001 From: Seena Nair <55585488+seenanair@users.noreply.github.com> Date: Mon, 19 Aug 2024 14:25:12 +0100 Subject: [PATCH 36/61] Prettier runs --- spec/lib/add_missing_asset_audit_records_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lib/add_missing_asset_audit_records_spec.rb b/spec/lib/add_missing_asset_audit_records_spec.rb index 1e3b1c1b9a..21fb5d5a8d 100644 --- a/spec/lib/add_missing_asset_audit_records_spec.rb +++ b/spec/lib/add_missing_asset_audit_records_spec.rb @@ -15,7 +15,7 @@ end it 'outputs an error message and returns' do - expect { run_rake_task }.to raise_error(RuntimeError,/Please provide a valid file path/) + expect { run_rake_task }.to raise_error(RuntimeError, /Please provide a valid file path/) end end @@ -28,7 +28,7 @@ end it 'outputs an error message and return' do - expect { run_rake_task }.to raise_error(RuntimeError,/Failed to read CSV file/) + expect { run_rake_task }.to raise_error(RuntimeError, /Failed to read CSV file/) end end @@ -40,7 +40,7 @@ end it 'outputs an error message and return' do - expect { run_rake_task }.to raise_error(RuntimeError, 'Failed to read CSV file: Missing columns.') + expect { run_rake_task }.to raise_error(RuntimeError, 'Failed to read CSV file: Missing columns.') end end From b3752ea850d26143efcaaa091d3a3e927f4bb8ed Mon Sep 17 00:00:00 2001 From: yoldas Date: Mon, 19 Aug 2024 14:52:16 +0100 Subject: [PATCH 37/61] Updated the command with optional title and attribute parameters --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 989a9676c0..04afba50ba 100644 --- a/README.md +++ b/README.md @@ -461,10 +461,11 @@ Copyright (c) 2007, 2010-2021 Genome Research Ltd. ### ERD -You can create a database entity relationship diagram and view the output: +You can create a database entity relationship diagram, by specifying the title and attributes optionally, and view the output: ``` -bundle exec erd +bundle exec rake erd title='Sequencescape Entity Relationship Diagram' attributes='primary_keys,foreign_keys,inheritance' orientation=horizontal polymorphism=true notation=bachman indirect=false inheritance=true only='Sample,Study,AliquotIndex,Aliquot,Project,Order,Submission,Labware,Receptacle,Request,Request::Metadata,Batch,BatchRequest,LabEvent,RequestType,Pipeline,SampleManifest,Sample::Metadata,Study::Metadata,Item,BaitLibrary,RequestEvent,Project::Metadata,Barcode,Purpose,QCResult,QCAssay,User,Plate,Tube,Well' exclude='Target,Commentable,Failable,Eventful,Eventable,Resource,Attributable,Owner,Authorizable,Documentable' + open erd.pdf ``` The command uses the [rails-erd](https://github.com/voormedia/rails-erd) gem. \ No newline at end of file From 30fa7388d3443ac4b683ca123553dbdbb0855c2a Mon Sep 17 00:00:00 2001 From: yoldas Date: Mon, 19 Aug 2024 16:08:44 +0100 Subject: [PATCH 38/61] Prettier --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04afba50ba..f061a26b83 100644 --- a/README.md +++ b/README.md @@ -468,4 +468,5 @@ bundle exec rake erd title='Sequencescape Entity Relationship Diagram' attribute open erd.pdf ``` -The command uses the [rails-erd](https://github.com/voormedia/rails-erd) gem. \ No newline at end of file + +The command uses the [rails-erd](https://github.com/voormedia/rails-erd) gem. From 26c2d6aceab1c1ab8b7775289b65872d170d65c9 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 20 Aug 2024 09:55:59 +0100 Subject: [PATCH 39/61] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 99ce2c4ba2..997736db8f 100644 --- a/README.md +++ b/README.md @@ -64,18 +64,14 @@ a organisation of 900 people. ## Documentation -In addition to the [externally hosted YARD docs](https://www.rubydoc.info/github/sanger/sequencescape), you can also run a local server: +The Yard documentation is also hosted at [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). The documentation is automatically updated via a CI workflow when a merge to master occurs, but you can also trigger it manually against any branch (the branch can be selected using the "Run Workflow" button in the [corresponding action](https://github.com/sanger/sequencescape/actions/workflows/generate_pages.yml)). + +To preview this documentation, you can spin up a yard server locally using the following command: ```shell yard server -r --gems -m sequencescape . ``` -You can then access the Sequencescape documentation through: [http://localhost:8808/docs/sequencescape](http://localhost:8808/docs/sequencescape) - -Yard will also try and document the installed gems: [http://localhost:8808/docs](http://localhost:8808/docs) - -The Yard documentation is also hosted in [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). Each `master` merge (i.e., release) would trigger a CI action (`.github/workflows/generate_pages.yml`) that deploy the Yard docs to GitHub Pages. This workflow can also be triggered via `workflow_dispatch` event which means it could be triggered manually through the "Deploy Yard to GitHub Pages" action in Actions tab in sequencescape repository. - ### Linting Yard-Junk is used to check for missing or incorrect documentation. To run the checks: From d1f04f6a546f38b041c2b7fa86f563c2b4a2ebf3 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 20 Aug 2024 09:58:09 +0100 Subject: [PATCH 40/61] misc: renames rvi bcl submission template name --- .../010_rvi_bait_capture_library_submission_templates.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml index cab17a4fbd..1f02536485 100644 --- a/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml +++ b/config/default_records/submission_templates/010_rvi_bait_capture_library_submission_templates.yml @@ -1,7 +1,6 @@ # This submission template is associated with the Limber Bait Capture Library preparation pipeline. -# To create this run WIP=010_bait_capture_library_submission_templates rake record_loader:all --- -Limber-Htp - RVI - Bait Capture Library: +Limber-Htp - RVI Bait Capture Library - NovaSeq 6000 Paired end sequencing: submission_class_name: "LinearSubmission" related_records: request_type_keys: From 714132052eed1a0633f94220020515da571a5b9d Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 20 Aug 2024 10:01:56 +0100 Subject: [PATCH 41/61] Making prettier happy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 997736db8f..b61312b463 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ a organisation of 900 people. ## Documentation -The Yard documentation is also hosted at [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). The documentation is automatically updated via a CI workflow when a merge to master occurs, but you can also trigger it manually against any branch (the branch can be selected using the "Run Workflow" button in the [corresponding action](https://github.com/sanger/sequencescape/actions/workflows/generate_pages.yml)). +The Yard documentation is also hosted at [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). The documentation is automatically updated via a CI workflow when a merge to master occurs, but you can also trigger it manually against any branch (the branch can be selected using the "Run Workflow" button in the [corresponding action](https://github.com/sanger/sequencescape/actions/workflows/generate_pages.yml)). To preview this documentation, you can spin up a yard server locally using the following command: From fa5b003db8ea9d41f84b8f10dd8d4d70cdfe4ca0 Mon Sep 17 00:00:00 2001 From: Dasun Pubudumal Date: Tue, 20 Aug 2024 11:14:43 +0100 Subject: [PATCH 42/61] Update README.md Co-authored-by: Stuart McHattie --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b61312b463..c58e67c567 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ a organisation of 900 people. ## Documentation -The Yard documentation is also hosted at [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). The documentation is automatically updated via a CI workflow when a merge to master occurs, but you can also trigger it manually against any branch (the branch can be selected using the "Run Workflow" button in the [corresponding action](https://github.com/sanger/sequencescape/actions/workflows/generate_pages.yml)). +The Yard documentation is also hosted at [GitHub Pages](https://pages.github.com/) under [https://sanger.github.io/sequencescape/](https://sanger.github.io/sequencescape/). +The documentation is automatically updated via a CI workflow when a merge to master occurs, but you can also trigger it manually against any branch (the branch can be selected using the "Run Workflow" button in the [corresponding action](https://github.com/sanger/sequencescape/actions/workflows/generate_pages.yml)). To preview this documentation, you can spin up a yard server locally using the following command: From cc4efbbe24b3039abccaa8ed6bc877912e5770d7 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 21 Aug 2024 10:48:40 +0100 Subject: [PATCH 43/61] remove directory parameter in wip_list method --- lib/record_loader/application_record_loader.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 38d0cc5617..895de35cb8 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +require 'find' # This file was automatically generated by `rails g record_loader` module RecordLoader @@ -10,12 +11,13 @@ class ApplicationRecordLoader < RecordLoader::Base # @see https://rubydoc.info/github/sanger/record_loader/RecordLoader/Adapter adapter RecordLoader::Adapter::Rails.new - def wip_list(directory) + def wip_list wip_files = [] - Find.find(directory) do |path| - files << path if path =~ /\wip\.yml$/ + wip_files_path = Rails.root.join('config','default_records') + Find.find(wip_files_path) do |path| + wip_files << path if path =~ /\wip\.yml$/ end - files + wip_files end end end From 16f4d4ed8f2dfb4162316b38ab63b373ebba4158 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 21 Aug 2024 11:02:08 +0100 Subject: [PATCH 44/61] fix the formatting --- lib/record_loader/application_record_loader.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 895de35cb8..a73ba5651f 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'find' +require 'find' # This file was automatically generated by `rails g record_loader` module RecordLoader @@ -10,13 +10,11 @@ class ApplicationRecordLoader < RecordLoader::Base # Uses the standard RailsAdapter # @see https://rubydoc.info/github/sanger/record_loader/RecordLoader/Adapter adapter RecordLoader::Adapter::Rails.new - + def wip_list wip_files = [] - wip_files_path = Rails.root.join('config','default_records') - Find.find(wip_files_path) do |path| - wip_files << path if path =~ /\wip\.yml$/ - end + wip_files_path = Rails.root.join('config', 'default_records') + Find.find(wip_files_path) { |path| wip_files << path if path =~ /\wip\.yml$/ } wip_files end end From e6b326ff3b767678abc21f53d305ddf188ac440a Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 21 Aug 2024 14:49:57 +0100 Subject: [PATCH 45/61] fix the format --- lib/record_loader/application_record_loader.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index a73ba5651f..20e87ac89a 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -13,8 +13,8 @@ class ApplicationRecordLoader < RecordLoader::Base def wip_list wip_files = [] - wip_files_path = Rails.root.join('config', 'default_records') - Find.find(wip_files_path) { |path| wip_files << path if path =~ /\wip\.yml$/ } + wip_files_path = Rails.root.join("config/default_records") + Find.find(wip_files_path) { |path| wip_files << path if /\wip\.yml$/.match?(path) } wip_files end end From 401cfa541df612afc0b11034ff5ea0797baedf36 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 21 Aug 2024 14:58:49 +0100 Subject: [PATCH 46/61] fix the format --- lib/record_loader/application_record_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 20e87ac89a..32e909b8f8 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -13,7 +13,7 @@ class ApplicationRecordLoader < RecordLoader::Base def wip_list wip_files = [] - wip_files_path = Rails.root.join("config/default_records") + wip_files_path = Rails.root.join('config/default_records') Find.find(wip_files_path) { |path| wip_files << path if /\wip\.yml$/.match?(path) } wip_files end From d60b6bfd8fd6948910a50c8fe46db06acf24795d Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 21 Aug 2024 15:38:00 +0100 Subject: [PATCH 47/61] add deploy_wip_pipeline environment variable --- config/environments/development.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index 03eb9d6529..3247fea461 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -71,6 +71,8 @@ Bullet.bullet_logger = true Bullet.rails_logger = true end + + config.deploy_wip_pipelines = true end Rack::MiniProfiler.config.position = 'right' From e8d14fcb72efadfc2a6c24b44d88179478674a8e Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 22 Aug 2024 10:25:07 +0100 Subject: [PATCH 48/61] modify the wip_list to return file base name rather than file path --- lib/record_loader/application_record_loader.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 32e909b8f8..a6a8a03aee 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -14,7 +14,12 @@ class ApplicationRecordLoader < RecordLoader::Base def wip_list wip_files = [] wip_files_path = Rails.root.join('config/default_records') - Find.find(wip_files_path) { |path| wip_files << path if /\wip\.yml$/.match?(path) } + Find.find(wip_files_path) do |path| + if path.match?(/\wip\.yml$/) + file_name = File.basename(path, '.wip.yml') + wip_files << file_name + end + end wip_files end end From 35101958fa79530cc7c807d92225fe84ec4909dc Mon Sep 17 00:00:00 2001 From: sabrine33 Date: Thu, 22 Aug 2024 12:14:03 +0100 Subject: [PATCH 49/61] =?UTF-8?q?Fields=20=E2=80=9CRequest=20type=E2=80=9D?= =?UTF-8?q?,=20=E2=80=9CRead=20length=E2=80=9D=20and=20=E2=80=9CFlowcell?= =?UTF-8?q?=20type=20should=20default=20to=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/receptacles/new_request.html.erb | 2 +- .../shared/metadata/edit/_request.html.erb | 2 +- spec/features/assets/asset_submission_spec.rb | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/views/receptacles/new_request.html.erb b/app/views/receptacles/new_request.html.erb index b1b1d489d9..15ad3215ed 100644 --- a/app/views/receptacles/new_request.html.erb +++ b/app/views/receptacles/new_request.html.erb @@ -9,7 +9,7 @@ <% instance_variable_or_id_param(:request_type) do |field_name, value| %>
<%= label_tag(field_name, 'Request type', class: 'col-md-4') %> - <%= select_field_sorted_by_name(field_name, @request_types, value, can_edit) %> + <%= select_field_sorted_by_name(field_name, @request_types, value, can_edit, prompt: 'Select a request type', required: true) %>
<% end %> <% if @asset.studies.uniq.count > 1 -%> diff --git a/app/views/shared/metadata/edit/_request.html.erb b/app/views/shared/metadata/edit/_request.html.erb index ee380c1a54..b62a5318cc 100644 --- a/app/views/shared/metadata/edit/_request.html.erb +++ b/app/views/shared/metadata/edit/_request.html.erb @@ -5,7 +5,7 @@ <%- request.request_metadata.field_infos.each do |field_info| %> <%- if field_info.selection %> - <%= metadata_fields.select(field_info.key, field_info.selection) %> + <%= metadata_fields.select(field_info.key, field_info.selection, { prompt: "Select a #{field_info.key.to_s.gsub( '_', ' ')}" }) %> <%- elsif field_info.kind == FieldInfo::BOOLEAN %> <%= metadata_fields.check_box(field_info.key) %> <%- elsif field_info.kind == FieldInfo::NUMERIC %> diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index e7bdfa5247..68fb94a5e7 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -15,6 +15,36 @@ create(request_factory, study: study, project: project, asset: asset, request_type: original_request_type) end + describe 'The request form does not set default values' do + let(:user) { create :admin } + + before do + login_user user + visit labware_path(asset) + click_link 'Request additional sequencing' + end + + describe 'when the form is loaded' do + it 'does not set request type' do + expect(page).to have_select('Request type', selected: 'Select a request type') + end + end + + describe 'when the user selects a request type' do + before do + select 'Request Type 1', from: 'Request type' + end + + it 'does not set flowcell type to default value' do + expect(page).to have_select('Flowcell type', selected: 'Select a requested flowcell type') + end + + it 'does not set read length to default value' do + expect(page).to have_select('Read length', selected: 'Select a read length') + end + end + end + shared_examples 'it allows additional sequencing' do it 'request additional sequencing' do login_user user From 310bbcb06d7730d156da89f221ef55e4f9a9dd55 Mon Sep 17 00:00:00 2001 From: sabrine33 Date: Thu, 22 Aug 2024 12:18:11 +0100 Subject: [PATCH 50/61] linting the code --- spec/features/assets/asset_submission_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/features/assets/asset_submission_spec.rb b/spec/features/assets/asset_submission_spec.rb index 68fb94a5e7..336e185ab7 100644 --- a/spec/features/assets/asset_submission_spec.rb +++ b/spec/features/assets/asset_submission_spec.rb @@ -31,9 +31,7 @@ end describe 'when the user selects a request type' do - before do - select 'Request Type 1', from: 'Request type' - end + before { select 'Request Type 1', from: 'Request type' } it 'does not set flowcell type to default value' do expect(page).to have_select('Flowcell type', selected: 'Select a requested flowcell type') From af301823bb5c79af3083fff81a4637030713caca Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 22 Aug 2024 13:25:15 +0100 Subject: [PATCH 51/61] add config wip flag option in wip_list method --- lib/record_loader/application_record_loader.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index a6a8a03aee..a2d5694233 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -12,15 +12,19 @@ class ApplicationRecordLoader < RecordLoader::Base adapter RecordLoader::Adapter::Rails.new def wip_list - wip_files = [] - wip_files_path = Rails.root.join('config/default_records') - Find.find(wip_files_path) do |path| - if path.match?(/\wip\.yml$/) - file_name = File.basename(path, '.wip.yml') - wip_files << file_name + if Rails.application.config.deploy_wip_pipelines + wip_files = [] + wip_files_path = Rails.root.join('config/default_records') + Find.find(wip_files_path) do |path| + if path.match?(/\wip\.yml$/) + file_name = File.basename(path, '.wip.yml') + wip_files << file_name + end end + wip_files + else + [] end - wip_files end end end From ffca885ed3ad55922f59bea1551313016da79a08 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 22 Aug 2024 13:35:08 +0100 Subject: [PATCH 52/61] fix formating --- .../application_record_loader.rb | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index a2d5694233..c393467176 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -12,19 +12,17 @@ class ApplicationRecordLoader < RecordLoader::Base adapter RecordLoader::Adapter::Rails.new def wip_list - if Rails.application.config.deploy_wip_pipelines - wip_files = [] - wip_files_path = Rails.root.join('config/default_records') - Find.find(wip_files_path) do |path| - if path.match?(/\wip\.yml$/) - file_name = File.basename(path, '.wip.yml') - wip_files << file_name - end + return [] unless Rails.application.config.deploy_wip_pipelines + + wip_files = [] + wip_files_path = Rails.root.join('config/default_records') + Find.find(wip_files_path) do |path| + if path.match?(/\wip\.yml$/) + file_name = File.basename(path, '.wip.yml') + wip_files << file_name end - wip_files - else - [] end + wip_files end end end From 69ce5037326c264fb8c9d5a7fab1be4657070cd4 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 22 Aug 2024 14:05:56 +0100 Subject: [PATCH 53/61] adding to handle if flag not set --- lib/record_loader/application_record_loader.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index c393467176..cbd066a8e3 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -12,7 +12,15 @@ class ApplicationRecordLoader < RecordLoader::Base adapter RecordLoader::Adapter::Rails.new def wip_list - return [] unless Rails.application.config.deploy_wip_pipelines + deploy_wip_pipelines = + ( + if Rails.application.config.respond_to?(:deploy_wip_pipelines) + Rails.application.config.deploy_wip_pipelines + else + false + end + ) + return [] unless deploy_wip_pipelines wip_files = [] wip_files_path = Rails.root.join('config/default_records') From 22d04b43b62a430555c3f94a117cf1aaff36664b Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Thu, 22 Aug 2024 14:39:11 +0100 Subject: [PATCH 54/61] refactor wip method --- lib/record_loader/application_record_loader.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index cbd066a8e3..9d7aa2a1a0 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -12,14 +12,7 @@ class ApplicationRecordLoader < RecordLoader::Base adapter RecordLoader::Adapter::Rails.new def wip_list - deploy_wip_pipelines = - ( - if Rails.application.config.respond_to?(:deploy_wip_pipelines) - Rails.application.config.deploy_wip_pipelines - else - false - end - ) + deploy_wip_pipelines = Rails.application.config.try(:deploy_wip_pipelines) || false return [] unless deploy_wip_pipelines wip_files = [] From f86cfdcfdf9cd0ba2a59260f5e4095ebea5bb45f Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:12:11 +0000 Subject: [PATCH 55/61] Update rexml to version 3.3.6 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e256d8391a..3fa56c1de6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -387,7 +387,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.4) + rexml (3.3.6) strscan roo (2.10.1) nokogiri (~> 1) From df8acfb0cd41a56af4bb78df1fa4dbfc3115c49e Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Fri, 23 Aug 2024 18:39:51 +0100 Subject: [PATCH 56/61] add test for wip_list method --- config/environments/development.rb | 1 + .../application_record_loader.rb | 3 +- .../application_record_loader_spec.rb | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 spec/lib/record_loader/application_record_loader_spec.rb diff --git a/config/environments/development.rb b/config/environments/development.rb index 3247fea461..d633043d05 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -72,6 +72,7 @@ Bullet.rails_logger = true end + # load WIP features flag config.deploy_wip_pipelines = true end diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 9d7aa2a1a0..51cc250102 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -12,11 +12,12 @@ class ApplicationRecordLoader < RecordLoader::Base adapter RecordLoader::Adapter::Rails.new def wip_list + # return a list of WIP files name as features if deploy_wip_pipelines is set to true, or return empty list deploy_wip_pipelines = Rails.application.config.try(:deploy_wip_pipelines) || false return [] unless deploy_wip_pipelines wip_files = [] - wip_files_path = Rails.root.join('config/default_records') + wip_files_path = @path Find.find(wip_files_path) do |path| if path.match?(/\wip\.yml$/) file_name = File.basename(path, '.wip.yml') diff --git a/spec/lib/record_loader/application_record_loader_spec.rb b/spec/lib/record_loader/application_record_loader_spec.rb new file mode 100644 index 0000000000..8f55825505 --- /dev/null +++ b/spec/lib/record_loader/application_record_loader_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'rails_helper' +require 'record_loader/application_record_loader' + +RSpec.describe RecordLoader::ApplicationRecordLoader, :loader, type: :model do + def a_new_record_loader + described_class.new(directory: test_directory) + end + + subject(:record_loader) { a_new_record_loader } + + let(:test_directory) { Rails.root.join('spec/data/record_loader/application_record_loader') } + + context 'when deploy_wip_pipelines is false' do + before { allow(Rails.application.config).to receive(:deploy_wip_pipelines).and_return(false) } + + it 'returns an empty array' do + expect(record_loader.wip_list).to eq([]) + end + end + + context 'when deploy_wip_pipelines is true' do + before do + allow(Rails.application.config).to receive(:deploy_wip_pipelines).and_return(true) + allow(Find).to receive(:find).with(test_directory).and_yield("#{test_directory}/example.wip.yml") + end + + it 'returns a list of WIP features' do + expect(record_loader.wip_list).to eq(['example']) + end + end + + context 'when deploy_wip_pipelines is not set' do + before { allow(Rails.application.config).to receive(:deploy_wip_pipelines).and_return(nil) } + + it 'returns an empty array' do + expect(record_loader.wip_list).to eq([]) + end + end +end From 68e710e1e044d916cecb5490ccc3a5305a8644ae Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Fri, 23 Aug 2024 20:06:18 +0100 Subject: [PATCH 57/61] add test config & test file --- config/environments/test.rb | 3 ++ .../application_record_loader/example.wip.yml | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 spec/data/record_loader/application_record_loader/example.wip.yml diff --git a/config/environments/test.rb b/config/environments/test.rb index 1cd73956ed..b118bfe8c2 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -50,4 +50,7 @@ # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true + + # load WIP features flag + config.deploy_wip_pipelines = true end diff --git a/spec/data/record_loader/application_record_loader/example.wip.yml b/spec/data/record_loader/application_record_loader/example.wip.yml new file mode 100644 index 0000000000..e4fc108981 --- /dev/null +++ b/spec/data/record_loader/application_record_loader/example.wip.yml @@ -0,0 +1,40 @@ +# Submission templates for the aggregation and library prep parts of the scRNA Core pipeline. +--- +Limber-Htp - scRNA Core Aggregation: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: ["limber_scrna_core_aggregation"] + product_line_name: Short Read + product_catalogue_name: scRNA Core +Limber-Htp - scRNA Core Library Prep: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: ["limber_scrna_core_library_prep"] + product_line_name: Short Read + product_catalogue_name: scRNA Core +Limber-Htp - scRNA Core Library Prep - Pool: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: ["limber_scrna_core_library_prep", "limber_multiplexing"] + product_line_name: Short Read + product_catalogue_name: scRNA Core +Limber-Htp - scRNA Core Library Prep - NovaSeqX paired end sequencing: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: + ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_htp_novaseqx_paired_end_sequencing"] + product_line_name: Short Read + product_catalogue_name: scRNA Core +Limber-Htp - scRNA Core Library Prep - NovaSeq 6000 paired end sequencing: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: + ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_htp_novaseq_6000_paired_end_sequencing"] + product_line_name: Short Read + product_catalogue_name: scRNA Core +Limber-Htp - scRNA Core Library Prep - MiSeq sequencing: + submission_class_name: "LinearSubmission" + related_records: + request_type_keys: ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_b_miseq_sequencing"] + product_line_name: Short Read + product_catalogue_name: scRNA Core From aa5d6be9642ec9c359417c41de56596b8a4ee0e5 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:55:21 +0000 Subject: [PATCH 58/61] Update bootsnap to version 1.18.4 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3fa56c1de6..fe48295ff6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,7 +118,7 @@ GEM backports (3.25.0) base64 (0.2.0) bigdecimal (3.1.8) - bootsnap (1.18.3) + bootsnap (1.18.4) msgpack (~> 1.2) builder (3.3.0) bullet (7.2.0) From 9949dec9036c6ee30dfe45053b5ec34acfef5455 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Tue, 27 Aug 2024 16:24:45 +0100 Subject: [PATCH 59/61] simplify test file & add comments --- .../application_record_loader.rb | 2 + .../application_record_loader/example.wip.yml | 42 ++----------------- 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 51cc250102..961a9c07c6 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -17,6 +17,8 @@ def wip_list return [] unless deploy_wip_pipelines wip_files = [] + # @path returns 'config/default_records' directory + # see https://github.com/sanger/record_loader/blob/master/lib/record_loader/base.rb wip_files_path = @path Find.find(wip_files_path) do |path| if path.match?(/\wip\.yml$/) diff --git a/spec/data/record_loader/application_record_loader/example.wip.yml b/spec/data/record_loader/application_record_loader/example.wip.yml index e4fc108981..51074a83b0 100644 --- a/spec/data/record_loader/application_record_loader/example.wip.yml +++ b/spec/data/record_loader/application_record_loader/example.wip.yml @@ -1,40 +1,4 @@ -# Submission templates for the aggregation and library prep parts of the scRNA Core pipeline. +# Test record loader records --- -Limber-Htp - scRNA Core Aggregation: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: ["limber_scrna_core_aggregation"] - product_line_name: Short Read - product_catalogue_name: scRNA Core -Limber-Htp - scRNA Core Library Prep: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: ["limber_scrna_core_library_prep"] - product_line_name: Short Read - product_catalogue_name: scRNA Core -Limber-Htp - scRNA Core Library Prep - Pool: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: ["limber_scrna_core_library_prep", "limber_multiplexing"] - product_line_name: Short Read - product_catalogue_name: scRNA Core -Limber-Htp - scRNA Core Library Prep - NovaSeqX paired end sequencing: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: - ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_htp_novaseqx_paired_end_sequencing"] - product_line_name: Short Read - product_catalogue_name: scRNA Core -Limber-Htp - scRNA Core Library Prep - NovaSeq 6000 paired end sequencing: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: - ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_htp_novaseq_6000_paired_end_sequencing"] - product_line_name: Short Read - product_catalogue_name: scRNA Core -Limber-Htp - scRNA Core Library Prep - MiSeq sequencing: - submission_class_name: "LinearSubmission" - related_records: - request_type_keys: ["limber_scrna_core_library_prep", "limber_multiplexing", "illumina_b_miseq_sequencing"] - product_line_name: Short Read - product_catalogue_name: scRNA Core +Test Record: + test_attribute: "A Value" From 8b3bbe9d11bece03a4fcdbea37d3a66d175902ed Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:39:22 +0000 Subject: [PATCH 60/61] Update rspec-rails to version 6.1.4 --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fe48295ff6..5051fffc5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,7 +154,7 @@ GEM choice (0.2.0) chronic (0.10.2) coderay (1.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) configatron (4.5.1) connection_pool (2.4.1) crack (1.0.0) @@ -275,7 +275,7 @@ GEM mime-types-data (3.2024.0305) mini_magick (4.12.0) mini_mime (1.1.5) - minitest (5.24.1) + minitest (5.25.1) minitest-profiler (0.0.2) activesupport (>= 4.1.0) minitest (>= 5.3.3) @@ -400,7 +400,7 @@ GEM rspec-expectations (>= 2.99.0.beta1) rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-github (2.4.0) @@ -414,7 +414,7 @@ GEM rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.3) + rspec-rails (6.1.4) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) From d3cd4334a3161e9ba8e09c133ebb62f73dbaab09 Mon Sep 17 00:00:00 2001 From: Wendy Yang Date: Wed, 28 Aug 2024 16:13:24 +0100 Subject: [PATCH 61/61] update the comments for @path in wip_list method --- lib/record_loader/application_record_loader.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/record_loader/application_record_loader.rb b/lib/record_loader/application_record_loader.rb index 961a9c07c6..52a2af1ecc 100644 --- a/lib/record_loader/application_record_loader.rb +++ b/lib/record_loader/application_record_loader.rb @@ -17,7 +17,8 @@ def wip_list return [] unless deploy_wip_pipelines wip_files = [] - # @path returns 'config/default_records' directory + # @path is initialised from the directory argument passed to the initialiser method of the super class. + # By default, it returns 'config/default_records' directory # see https://github.com/sanger/record_loader/blob/master/lib/record_loader/base.rb wip_files_path = @path Find.find(wip_files_path) do |path|