Class: JobPacks::JobPack

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

Instance Method Summary collapse

Instance Method Details

#add_item(item) ⇒ Object



5
6
7
# File 'lib/job_packs/job_pack.rb', line 5

def add_item(item)
  job_pack_items << item
end

#progressObject



19
20
21
# File 'lib/job_packs/job_pack.rb', line 19

def progress
  ((total_items_done.to_f * 100) / total_items.to_f).to_f
end

#total_itemsObject



23
24
25
# File 'lib/job_packs/job_pack.rb', line 23

def total_items
  job_pack_items.count.to_i
end

#update_progress(force_item_refresh = false) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/job_packs/job_pack.rb', line 9

def update_progress(force_item_refresh = false )
  job_pack_items.each(&:refresh_job_status) if force_item_refresh
  self.total_items_with_error = job_pack_items.error.count
  self.total_items_waiting = job_pack_items.waiting.count
  self.total_items_running = job_pack_items.running.count
  self.total_items_done = job_pack_items.done.count
  self.done = total_items_done == total_items
  save!
end