Class: Sidekiq::Batch::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/batch/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bid) ⇒ Status

Returns a new instance of Status.



6
7
8
# File 'lib/sidekiq/batch/status.rb', line 6

def initialize(bid)
  @bid = bid
end

Instance Attribute Details

#bidObject (readonly)

Returns the value of attribute bid.



4
5
6
# File 'lib/sidekiq/batch/status.rb', line 4

def bid
  @bid
end

Instance Method Details

#child_countObject



42
43
44
# File 'lib/sidekiq/batch/status.rb', line 42

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

#complete?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/sidekiq/batch/status.rb', line 38

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

#created_atObject



22
23
24
# File 'lib/sidekiq/batch/status.rb', line 22

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

#dataObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sidekiq/batch/status.rb', line 46

def data
  {
    bid: bid,
    total: total,
    failures: failures,
    pending: pending,
    created_at: created_at,
    complete: complete?,
    failure_info: failure_info,
    parent_bid: parent_bid,
    child_count: child_count
  }
end

#failure_infoObject



34
35
36
# File 'lib/sidekiq/batch/status.rb', line 34

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

#failuresObject



18
19
20
# File 'lib/sidekiq/batch/status.rb', line 18

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

#joinObject



10
11
12
# File 'lib/sidekiq/batch/status.rb', line 10

def join
  raise "Not supported"
end

#parent_bidObject



30
31
32
# File 'lib/sidekiq/batch/status.rb', line 30

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

#pendingObject



14
15
16
# File 'lib/sidekiq/batch/status.rb', line 14

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

#totalObject



26
27
28
# File 'lib/sidekiq/batch/status.rb', line 26

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