From 1154c7c8e621bb0edecaa55404f0daa2bae887f4 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Wed, 27 Dec 2023 18:00:46 +0100 Subject: [PATCH] add option to force submission archiving even if already archived --- bin/ncbo_ontology_archive_old_submissions | 13 +++++++++---- lib/ncbo_cron/ontology_helper.rb | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/ncbo_ontology_archive_old_submissions b/bin/ncbo_ontology_archive_old_submissions index 1b2268a5..34fe073c 100755 --- a/bin/ncbo_ontology_archive_old_submissions +++ b/bin/ncbo_ontology_archive_old_submissions @@ -13,11 +13,15 @@ abort("Please create a config/config.rb file using the config/config.rb.sample a require_relative '../config/config' require 'optparse' -options = { delete: false } +options = { delete: false , force_archiving: false} opt_parser = OptionParser.new do |opts| # Set a banner, displayed at the top of the help screen. opts.banner = "Usage: #{File.basename(__FILE__)} [options]" + opts.on('-f', '--force-re-archiving', 'Force to re-archive already archived submissions.') do + options[:force_archiving] = true + end + options[:logfile] = STDOUT opts.on( '-l', '--logfile FILE', "Write log to FILE (default is STDOUT)" ) do |filename| options[:logfile] = filename @@ -40,12 +44,12 @@ logfile = options[:logfile] if File.file?(logfile); File.delete(logfile); end logger = Logger.new(logfile) process_actions = { process_rdf: false, generate_labels: false, index_search: false, index_commit: false, - process_annotator: false, diff: false, run_metrics: false, archive: true } + process_annotator: false, diff: false, run_metrics: false, archive: true } onts = LinkedData::Models::Ontology.all onts.each { |ont| ont.bring(:acronym, :submissions) } onts.sort! { |a, b| a.acronym <=> b.acronym } bad_submissions = {} - +force_archiving = options[:force_archiving] onts.each do |ont| latest_sub = ont.latest_submission @@ -73,7 +77,7 @@ onts.each do |ont| } old_subs.sort! { |a, b| a.submissionId <=> b.submissionId } old_subs.each do |sub| - unless sub.archived? + unless sub.archived? || force_archiving msg = "#{ont.acronym}: found un-archived old submission with ID #{sub.submissionId}." puts msg logger.info msg @@ -119,6 +123,7 @@ onts.each do |ont| end end + puts if bad_submissions.empty? diff --git a/lib/ncbo_cron/ontology_helper.rb b/lib/ncbo_cron/ontology_helper.rb index 42534768..4d1f0716 100644 --- a/lib/ncbo_cron/ontology_helper.rb +++ b/lib/ncbo_cron/ontology_helper.rb @@ -9,6 +9,7 @@ module OntologyHelper PROCESS_ACTIONS = { :process_rdf => true, :generate_labels => true, + :extract_metadata => true, :index_search => true, :index_properties => true, :run_metrics => true,