Method: Bj::Runner::Instance_Methods#archive_jobs
- Defined in:
- lib/bj/runner.rb
#archive_jobs ⇒ Object
310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/bj/runner.rb', line 310 def archive_jobs Bj.transaction do now = Time.now too_old = now - Bj.ttl jobs = Bj::Table::Job.find :all, :conditions => ["(state = 'finished' or state = 'dead') and submitted_at < ?", too_old] jobs.each do |job| Bj.logger.info{ "#{ job.title } - archived" } hash = job.to_hash.update(:archived_at => now) Bj::Table::JobArchive.create! hash job.destroy end end end |