Method: Resque::Status.status_ids

Defined in:
lib/resque_ui/overrides/resque_status/status.rb

.status_ids(range_start = nil, range_end = nil) ⇒ Object

Return the num most recent status/job UUIDs in reverse chronological order. override the gem to fix the ordering



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/resque_ui/overrides/resque_status/status.rb', line 10

def self.status_ids(range_start = nil, range_end = nil)
  unless range_end && range_start
    # Because we want a reverse chronological order, we need to get a range starting
    # by the higest negative number.
    redis.zrevrange(set_key, 0, -1) || []
  else
    # Because we want a reverse chronological order, we need to get a range starting
    # by the higest negative number. The ordering is transparent from the API user's
    # perspective so we need to convert the passed params
    if range_start == 0
      range_start = -1
    else
      range_start += 1
    end
    (redis.zrange(set_key, -(range_end.abs), -(range_start.abs)) || []).reverse
  end
end