diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index e9b1ae3c15..38cb4b50bd 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 ] @@ -164,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 @@ -188,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}" @@ -211,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