Class: CanvasSync::JobBatches::Batch::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_sync/job_batches/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bid) ⇒ Status

Returns a new instance of Status.



7
8
9
10
# File 'lib/canvas_sync/job_batches/status.rb', line 7

def initialize(bid)
  bid = bid.bid if bid.is_a?(Batch)
  @bid = bid
end

Instance Attribute Details

#bidObject (readonly)

Returns the value of attribute bid.



5
6
7
# File 'lib/canvas_sync/job_batches/status.rb', line 5

def bid
  @bid
end

Instance Method Details

#child_countObject



56
57
58
# File 'lib/canvas_sync/job_batches/status.rb', line 56

def child_count
  Batch.redis { |r| r.hget("BID-#{bid}", 'children') }.to_i
end

#complete?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/canvas_sync/job_batches/status.rb', line 48

def complete?
  'true' == Batch.redis { |r| r.hget("BID-#{bid}", 'complete') }
end

#completed_children_countObject



60
61
62
# File 'lib/canvas_sync/job_batches/status.rb', line 60

def completed_children_count
  Batch.redis { |r| r.scard("BID-#{bid}-batches-complete") }.to_i
end

#completed_countObject



28
29
30
# File 'lib/canvas_sync/job_batches/status.rb', line 28

def completed_count
  job_count - pending
end

#created_atObject



36
37
38
# File 'lib/canvas_sync/job_batches/status.rb', line 36

def created_at
  Batch.redis { |r| r.hget("BID-#{bid}", 'created_at') }
end

#dataObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/canvas_sync/job_batches/status.rb', line 72

def data
  {
    bid: bid,
    failures: failures,
    pending: pending,
    created_at: created_at,
    complete: complete?,
    success: success?,
    failure_info: failure_info,
    parent_bid: parent_bid,
    child_count: child_count,
    completed_children_count: completed_children_count,
    successful_children_count: successful_children_count,
    failed_children_count: failed_children_count,
  }
end

#deadObject



24
25
26
# File 'lib/canvas_sync/job_batches/status.rb', line 24

def dead
  Batch.redis { |r| r.scard("BID-#{bid}-dead") }.to_i
end

#failed_children_countObject



68
69
70
# File 'lib/canvas_sync/job_batches/status.rb', line 68

def failed_children_count
  Batch.redis { |r| r.scard("BID-#{bid}-batches-failed") }.to_i
end

#failure_infoObject



44
45
46
# File 'lib/canvas_sync/job_batches/status.rb', line 44

def failure_info
  Batch.redis { |r| r.smembers("BID-#{bid}-failed") } || []
end

#failuresObject



20
21
22
# File 'lib/canvas_sync/job_batches/status.rb', line 20

def failures
  Batch.redis { |r| r.scard("BID-#{bid}-failed") }.to_i
end

#job_countObject



32
33
34
# File 'lib/canvas_sync/job_batches/status.rb', line 32

def job_count
  Batch.redis { |r| r.hget("BID-#{bid}", "job_count") }.to_i
end

#joinObject



12
13
14
# File 'lib/canvas_sync/job_batches/status.rb', line 12

def join
  raise "Not supported"
end

#parent_bidObject



40
41
42
# File 'lib/canvas_sync/job_batches/status.rb', line 40

def parent_bid
  Batch.redis { |r| r.hget("BID-#{bid}", "parent_bid") }
end

#pendingObject



16
17
18
# File 'lib/canvas_sync/job_batches/status.rb', line 16

def pending
  Batch.redis { |r| r.hget("BID-#{bid}", 'pending') }.to_i
end

#success?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/canvas_sync/job_batches/status.rb', line 52

def success?
  'true' == Batch.redis { |r| r.hget("BID-#{bid}", 'success') }
end

#successful_children_countObject



64
65
66
# File 'lib/canvas_sync/job_batches/status.rb', line 64

def successful_children_count
  Batch.redis { |r| r.scard("BID-#{bid}-batches-success") }.to_i
end