diff --git a/app/jobs/field_slip_job.rb b/app/jobs/field_slip_job.rb index 266662aaf2..e7342c841d 100644 --- a/app/jobs/field_slip_job.rb +++ b/app/jobs/field_slip_job.rb @@ -4,18 +4,22 @@ class FieldSlipJob < ApplicationJob queue_as :default def perform(tracker_id) + extra_log("Start") log("Starting FieldSlipJob.perform(#{tracker_id})") cleanup_old_pdfs(tracker_id) tracker = FieldSlipJobTracker.find(tracker_id) raise(:field_slip_job_no_tracker.t) unless tracker + extra_log("Processing") tracker.processing icon = "public/logo-120.png" view = FieldSlipView.new(tracker, icon) view.render view.save_as(tracker.filepath) + extra_log("Done") tracker.done log("Done with FieldSlipJob.perform(#{tracker_id})") + extra_log("End") tracker.filepath end @@ -23,6 +27,12 @@ def perform(tracker_id) MAX_JOB_AGE = 1.week + def extra_log(msg) + open("/tmp/extra_log", "a") do |f| + f.write("#{msg}\n") + end + end + def cleanup_old_pdfs(tracker_id) FieldSlipJobTracker.where.not(id: tracker_id).find_each do |tracker| next unless tracker.updated_at < Time.zone.now - MAX_JOB_AGE