Class: ActiveRedisStats::Rank::Get

Inherits:
Base
  • Object
show all
Defined in:
lib/active_redis_stats/rank/get.rb

Class Method Summary collapse

Methods inherited from Base

primary_key

Methods inherited from Base

all_key, all_keys, day_key, day_keys, expiration, hour_key, hour_keys, interval_key, month_key, month_keys, year_key, year_keys

Class Method Details

.all(key, with_scores: false) ⇒ Object



10
11
12
13
14
# File 'lib/active_redis_stats/rank/get.rb', line 10

def all(key, with_scores: false)
  ActiveRedisDB::SortedSet
    .evaluate
    .all_reverse(primary_key(key), with_scores: with_scores) || []
end

.all_intervals(key, with_scores: false, format: :month, offset: 0) ⇒ Object



16
17
18
19
# File 'lib/active_redis_stats/rank/get.rb', line 16

def all_intervals(key, with_scores: false, format: :month, offset: 0)
  ikey = send("#{format}_key", offset: offset)
  all("#{key}:#{ikey}", with_scores: with_scores)
end

.between(key, with_scores: false, from:, to:) ⇒ Object



21
22
23
24
25
# File 'lib/active_redis_stats/rank/get.rb', line 21

def between(key, with_scores: false, from:, to:)
  ActiveRedisDB::SortedSet
    .evaluate
    .between_reverse(primary_key(key), from, to, with_scores: with_scores) || []
end

.between_intervals(key, with_scores: false, from:, to:, format: :month, offset: 0) ⇒ Object

rubocop:disable Metrics/ParameterLists



28
29
30
31
# File 'lib/active_redis_stats/rank/get.rb', line 28

def between_intervals(key, with_scores: false, from:, to:, format: :month, offset: 0)
  ikey = send("#{format}_key", offset: offset)
  between("#{key}:#{ikey}", with_scores: with_scores, from: from, to: to)
end

.bottom(key, with_scores: false, limit: LIMIT) ⇒ Object

rubocop:enable Metrics/ParameterLists



34
35
36
37
38
# File 'lib/active_redis_stats/rank/get.rb', line 34

def bottom(key, with_scores: false, limit: LIMIT)
  ActiveRedisDB::SortedSet
    .evaluate
    .between(primary_key(key), 1, limit, with_scores: with_scores) || []
end

.bottom_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0) ⇒ Object



40
41
42
43
# File 'lib/active_redis_stats/rank/get.rb', line 40

def bottom_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0)
  ikey = send("#{format}_key", offset: offset)
  bottom("#{key}:#{ikey}", with_scores: with_scores, limit: limit)
end

.top(key, with_scores: false, limit: LIMIT) ⇒ Object



45
46
47
48
49
# File 'lib/active_redis_stats/rank/get.rb', line 45

def top(key, with_scores: false, limit: LIMIT)
  ActiveRedisDB::SortedSet
    .evaluate
    .between_reverse(primary_key(key), 1, limit, with_scores: with_scores) || []
end

.top_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0) ⇒ Object



51
52
53
54
# File 'lib/active_redis_stats/rank/get.rb', line 51

def top_intervals(key, with_scores: false, limit: LIMIT, format: :month, offset: 0)
  ikey = send("#{format}_key", offset: offset)
  top("#{key}:#{ikey}", with_scores: with_scores, limit: limit)
end