From 916302c8e1f5e93b2a035d50b7f8ca61cd0c116e Mon Sep 17 00:00:00 2001 From: Stuart Owen Date: Wed, 13 Nov 2024 16:12:18 +0000 Subject: [PATCH] tweaked upgrade tasks only triggers rdf generate jobs if repository configured, otherwise just clears cache, and only does so on the first run for sample type policy updates, putc a . so progress can be seen rather than appearing frozen for large databases --- lib/tasks/seek_upgrades.rake | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index bb8ac46ae7..d7b4717488 100644 --- a/lib/tasks/seek_upgrades.rake +++ b/lib/tasks/seek_upgrades.rake @@ -9,7 +9,7 @@ namespace :seek do task upgrade_version_tasks: %i[ environment db:seed:007_sample_attribute_types - seek_rdf:generate + update_rdf update_observation_unit_policies fix_xlsx_marked_as_zip add_policies_to_existing_sample_types @@ -47,6 +47,22 @@ namespace :seek do end end + # if rdf repository enabled then generate jobs, otherwise just clear the cache. Only runs once + task(update_rdf: [:environment]) do + only_once('seek:update_rdf 1.16.0') do + if Seek::Rdf::RdfRepository.instance&.configured? + puts '... triggering rdf generation jobs' + Rake::Task['seek_rdf:generate'].invoke + else + path = Seek::Config.rdf_filestore_path + unless Dir.empty?(path) + puts "... clearing rdf cache at #{path}" + FileUtils.rm_rf(path, secure: true) + end + end + end + end + task(update_observation_unit_policies: [:environment]) do puts '..... creating observation unit policies ...' affected_obs_units = [] @@ -104,7 +120,8 @@ namespace :seek do policy.save st.update_column(:policy_id, policy.id) - end + end + putc('.') counter += 1 end end