Sha256: 4fd6372c4e6a8bb874fddd26728d3524f78a361de31e1617e601fdd4eed48978

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

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

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

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

    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

    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

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

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
misha-resque-web-0.1.1 app/helpers/resque_web/stats_helper.rb
misha-resque-web-0.1.0 app/helpers/resque_web/stats_helper.rb
misha-resque-web-0.0.9 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.9 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.8 app/helpers/resque_web/stats_helper.rb
resque-web-edge-1.0.0 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.7 app/helpers/resque_web/stats_helper.rb
resque-web-clone-0.0.7 app/helpers/resque_web/stats_helper.rb
resque-web-clone-0.0.6 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.6 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.5 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.4 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.3 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.2 app/helpers/resque_web/stats_helper.rb
resque-web-0.0.1 app/helpers/resque_web/stats_helper.rb