From b48860bec1957a525c7239f79c8038d8ec6d196c Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 5 Mar 2024 15:52:21 +0100 Subject: [PATCH] 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