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



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

def self.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



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

def self.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



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

def self.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



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

def self.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



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

def self.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



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

def self.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



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

def self.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



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

def self.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