70N/Anamespace :ontology do
70N/A desc 'Reanalyze old ontologies'
286N/A task :reanalyze_all => :environment do
70N/A Ontology.where(parent_id: nil, present: true).order('updated_at desc').
70N/A find_each do |ontology|
70N/A if ontology.current_version.nil?
70N/A begin
70N/A commit_oid = ontology.repository.git.get_file!(ontology.path).oid
70N/A ontology_version_options = OntologyVersionOptions.new(ontology.path,
70N/A User.where(admin: true).first)
70N/A
70N/A OntologySaver.new(ontology.repository).
70N/A save_ontology(commit_oid, ontology_version_options)
70N/A rescue GitRepository::PathNotFoundError
70N/A ontology.present = false
70N/A ontology.save!
70N/A end
70N/A else
70N/A OntologyParsingMigrationWorker.
70N/A perform_async([[ontology.current_version.id,
70N/A {fast_parse: false, files_to_parse_afterwards: []}, 1]])
70N/A Sidekiq::Client.push('queue' => 'hets-migration',
70N/A 'class' => OntologyParsingWorker,
70N/A 'args' => [[[ontology.current_version.id,
70N/A {fast_parse: false,
70N/A files_to_parse_afterwards: []}, 1]]])
70N/A end
70N/A end
70N/A end
70N/Aend
326N/A