mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-15 03:55:41 +08:00
0ef52ed9da
* Setup daily leaderboards backend (#2987) bruception * Setup daily leaderboards backend * Add enabled checks * Consistent naming * Add initial unit tests * Use more flexible daily leaderboard rule logic * Fix seed rule * Add LRU Cache + Rank Calculation * Use native functions * Optional daily leaderboard rank * Proper status code for invalid lb mode * Add result criteria check * Make daily leaderboard cache size configurable * Add Ape endpoint for daily leaderboard (#2997) * support for switching to viewing daily lbs * test * buttons * only checking daily if user has more than 2 hours typed * updated structure * setting rank if its undefined * only when daily * storing uid * fixed media queries * Daily leaderboards pagination (#3006) * Pagination * Remove with scores * Add daily leaderboard rank (#3014) Bruception * Add daily leaderboard rank * Remove unused import * Use object instead * Add client logic * Add limit checks * Announce top daily leaderboard results (#3017) * Add rank in daily leaderboard results (#3022) * not showing lb memory and top % on daily * Fix rank pagination * Actual fix * showing new rank Co-authored-by: Miodec <bartnikjack@gmail.com>
18 lines
519 B
Lua
18 lines
519 B
Lua
local redis_call = redis.call
|
|
local leaderboard_scores_key, leaderboard_results_key = KEYS[1], KEYS[2]
|
|
|
|
local min_rank = tonumber(ARGV[1])
|
|
local max_rank = tonumber(ARGV[2])
|
|
|
|
local results = {}
|
|
local scores_in_range = redis_call('ZRANGE', leaderboard_scores_key, min_rank, max_rank, 'REV')
|
|
|
|
for _, user_id in ipairs(scores_in_range) do
|
|
local result_data = redis_call('HGET', leaderboard_results_key, user_id)
|
|
|
|
if (result_data ~= nil) then
|
|
results[#results + 1] = result_data
|
|
end
|
|
end
|
|
|
|
return results
|