Projektstart
This commit is contained in:
28
backend/node_modules/bullmq/dist/esm/commands/includes/getJobSchedulerEveryNextMillis.lua
generated
vendored
Normal file
28
backend/node_modules/bullmq/dist/esm/commands/includes/getJobSchedulerEveryNextMillis.lua
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
local function getJobSchedulerEveryNextMillis(prevMillis, every, now, offset, startDate)
|
||||
local nextMillis
|
||||
if not prevMillis then
|
||||
if startDate then
|
||||
-- Assuming startDate is passed as milliseconds from JavaScript
|
||||
nextMillis = tonumber(startDate)
|
||||
nextMillis = nextMillis > now and nextMillis or now
|
||||
else
|
||||
nextMillis = now
|
||||
end
|
||||
else
|
||||
nextMillis = prevMillis + every
|
||||
-- check if we may have missed some iterations
|
||||
if nextMillis < now then
|
||||
nextMillis = math.floor(now / every) * every + every + (offset or 0)
|
||||
end
|
||||
end
|
||||
|
||||
if not offset or offset == 0 then
|
||||
local timeSlot = math.floor(nextMillis / every) * every;
|
||||
offset = nextMillis - timeSlot;
|
||||
end
|
||||
|
||||
-- Return a tuple nextMillis, offset
|
||||
return math.floor(nextMillis), math.floor(offset)
|
||||
end
|
||||
Reference in New Issue
Block a user