Skip to content

Commit

Permalink
Merge pull request seek4science#1773 from ELIXIR-Belgium/fix_seek_upg…
Browse files Browse the repository at this point in the history
…rade_tasks

Fix seek upgrade tasks
  • Loading branch information
kdp-cloud authored Mar 6, 2024
2 parents 6493c70 + b48860b commit 7e610f3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/tasks/seek_upgrades.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -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
Expand Down

0 comments on commit 7e610f3

Please sign in to comment.