mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-17 01:40:44 +00:00
test: avoid cooldown expiry sort allocation
This commit is contained in:
@@ -131,9 +131,15 @@ const authRuntimeMock = vi.hoisted(() => {
|
||||
continue;
|
||||
}
|
||||
const stats = store.usageStats?.[profileId];
|
||||
const expiry = [stats?.cooldownUntil, stats?.disabledUntil]
|
||||
.filter((value): value is number => isActive(value, ts))
|
||||
.toSorted((a, b) => a - b)[0];
|
||||
const cooldownUntil = stats?.cooldownUntil;
|
||||
const disabledUntil = stats?.disabledUntil;
|
||||
let expiry: number | undefined;
|
||||
if (isActive(cooldownUntil, ts)) {
|
||||
expiry = cooldownUntil;
|
||||
}
|
||||
if (isActive(disabledUntil, ts) && (expiry === undefined || disabledUntil < expiry)) {
|
||||
expiry = disabledUntil;
|
||||
}
|
||||
if (expiry !== undefined && (soonest === null || expiry < soonest)) {
|
||||
soonest = expiry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user