Skip to content

Commit

Permalink
chore: consider maxScore
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Jun 29, 2024
1 parent 66197b8 commit 5401174
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/commands/includes/getDelayedScore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
]]
local function getDelayedScore(delayedKey, timestamp, delay)
local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)
local minScore = delayedTimestamp * 0x1000
local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1

local result = rcall("ZREVRANGEBYSCORE", delayedKey, (delayedTimestamp + 1 ) * 0x1000 - 1,
delayedTimestamp * 0x1000, "WITHSCORES","LIMIT", 0, 1)
local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,
minScore, "WITHSCORES","LIMIT", 0, 1)
if #result then
local maxTimestamp = tonumber(result[2])
if maxTimestamp ~= nil then
return maxTimestamp + 1, delayedTimestamp
local currentMaxScore = tonumber(result[2])
if currentMaxScore ~= nil then
if currentMaxScore >= maxScore then
return maxScore, delayedTimestamp
else
return currentMaxScore + 1, delayedTimestamp
end
end
end
return delayedTimestamp * 0x1000, delayedTimestamp
return minScore, delayedTimestamp
end

0 comments on commit 5401174

Please sign in to comment.