Skip to content

Commit

Permalink
add option to force submission archiving even if already archived
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 27, 2023
1 parent 080629e commit 1154c7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bin/ncbo_ontology_archive_old_submissions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -119,6 +123,7 @@ onts.each do |ont|
end
end


puts

if bad_submissions.empty?
Expand Down
1 change: 1 addition & 0 deletions lib/ncbo_cron/ontology_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1154c7c

Please sign in to comment.