From 350d19650ad3050858aa1be84588e7d8e5393e7d Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 5 Mar 2024 15:28:56 +0100 Subject: [PATCH 1/3] Seed Minimal starter templates as upgrade task --- lib/tasks/seek_upgrades.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index e9b1ae3c15..0d284c5116 100644 --- a/lib/tasks/seek_upgrades.rake +++ b/lib/tasks/seek_upgrades.rake @@ -16,6 +16,7 @@ namespace :seek do remove_ontology_attribute_type db:seed:007_sample_attribute_types db:seed:001_create_controlled_vocabs + db:seed:017_minimal_starter_isa_templates recognise_isa_json_compliant_items implement_assay_streams_for_isa_assays ] From a75ee56c734f48f3811b24ac87a8aeead3215e15 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 5 Mar 2024 15:29:35 +0100 Subject: [PATCH 2/3] Also include investigations where is_isa_json_compliant is nil --- lib/tasks/seek_upgrades.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index 0d284c5116..47b4ab267c 100644 --- a/lib/tasks/seek_upgrades.rake +++ b/lib/tasks/seek_upgrades.rake @@ -165,7 +165,7 @@ namespace :seek do investigations_updated = 0 disable_authorization_checks do investigations_to_update = Study.joins(:investigation) - .where('investigations.is_isa_json_compliant = ?', false) + .where('investigations.is_isa_json_compliant IS NULL OR investigations.is_isa_json_compliant = ?', false) .select { |study| study.sample_types.any? } .map(&:investigation) .compact From b48860bec1957a525c7239f79c8038d8ec6d196c Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 5 Mar 2024 15:52:21 +0100 Subject: [PATCH 3/3] Fix assay streams upgrade task --- lib/tasks/seek_upgrades.rake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index 47b4ab267c..38cb4b50bd 100644 --- a/lib/tasks/seek_upgrades.rake +++ b/lib/tasks/seek_upgrades.rake @@ -189,7 +189,7 @@ namespace :seek do # Previous ST should be second ST of study first_assays_in_stream = Assay.joins(:sample_type, study: :investigation) .where(assay_stream_id: nil, investigation: { is_isa_json_compliant: true }) - .select { |a| a.previous_linked_sample_type == a.study.sample_types.second } + .select { |a| a.sample_type.previous_linked_sample_type == a.study.sample_types.second } first_assays_in_stream.map do |fas| stream_name = "Assay Stream - #{UUID.generate}" @@ -212,7 +212,11 @@ namespace :seek do current_assay.update_column(:assay_stream_id, assay_stream.id) assay_position += 1 - current_assay = current_assay.next_linked_child_assay + current_assay = if current_assay.sample_type.nil? + nil + else + current_assay.sample_type.next_linked_sample_types.first&.assays&.first + end end assay_streams_created += 1 end