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.



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

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.



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

def bid
  @bid
end

Instance Method Details

#child_countObject



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

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

#complete?Boolean

Returns:

  • (Boolean)


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

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

#completed_children_countObject



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

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

#completed_countObject



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

def completed_count
  job_count - pending
end

#created_atObject



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

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

#dataObject



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

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



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

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

#failed_children_countObject



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

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

#failure_infoObject



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

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

#failuresObject



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

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

#job_countObject



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

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

#joinObject



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

def join
  raise "Not supported"
end

#parent_bidObject



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

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

#pendingObject



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

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

#success?Boolean

Returns:

  • (Boolean)


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

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

#successful_children_countObject



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

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