Class: JobPacks::JobPackItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/job_packs/job_pack_item.rb

Constant Summary collapse

WAITING =
0
RUNNING =
1
ERROR =
2
DONE =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delayed_jobObject

Returns the value of attribute delayed_job.



29
30
31
# File 'lib/job_packs/job_pack_item.rb', line 29

def delayed_job
  @delayed_job
end

#old_statusObject

Returns the value of attribute old_status.



11
12
13
# File 'lib/job_packs/job_pack_item.rb', line 11

def old_status
  @old_status
end

Instance Method Details

#refresh_job_statusObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/job_packs/job_pack_item.rb', line 33

def refresh_job_status
  self.old_status = self.status
  self.status = if job
                  if !job.locked_at.nil?
                    RUNNING
                  elsif !job.last_error.nil?
                    ERROR
                  else
                    WAITING
                  end
                else
                  DONE
                end

  save! if changed?
end