Module: ResqueWeb::StatsHelper

Defined in:
app/helpers/resque_web/stats_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_subtab?(name) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/helpers/resque_web/stats_helper.rb', line 50

def current_subtab?(name)
  params[:action] == name.to_s
end

#redis_get_array(key, start = 0) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/resque_web/stats_helper.rb', line 33

def redis_get_array(key, start=0)
  case redis_key_type(key)
  when 'none'
    []
  when 'list'
    Resque.redis.lrange(key, start, start + 20)
  when 'set'
    Resque.redis.smembers(key)[start..(start + 20)]
  when 'string'
    [Resque.redis.get(key)]
  when 'zset'
    Resque.redis.zrange(key, start, start + 20)
  when 'hash'
    Resque.redis.hgetall(key)
  end
end

#redis_infoObject



7
8
9
# File 'app/helpers/resque_web/stats_helper.rb', line 7

def redis_info
  Resque.redis.info.to_a.sort_by { |i| i[0].to_s }
end

#redis_key_size(key) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/resque_web/stats_helper.rb', line 15

def redis_key_size(key)
  # FIXME: there's a potential race in this method if a key is modified
  # "in flight". Not sure how to fix it, unfortunately :(
  case redis_key_type(key)
  when 'none'
    0
  when 'list'
    Resque.redis.llen(key)
  when 'set'
    Resque.redis.scard(key)
  when 'string'
    string = Resque.redis.get(key)
    string ? string.length : 0
  when 'zset'
    Resque.redis.zcard(key)
  end
end

#redis_key_type(key) ⇒ Object



11
12
13
# File 'app/helpers/resque_web/stats_helper.rb', line 11

def redis_key_type(key)
  Resque.redis.type(key)
end

#resque_infoObject



3
4
5
# File 'app/helpers/resque_web/stats_helper.rb', line 3

def resque_info
  Resque.info.sort_by { |i| i[0].to_s }
end