fix(quota): accept epoch reset timestamps (#1241)

* fix(quota): accept epoch reset timestamps

* fix(quota): format epoch reset windows

---------

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-13 10:30:42 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent f059bc8dd6
commit c005c59186
2 changed files with 19 additions and 3 deletions
@@ -27,8 +27,10 @@ export const formatResetTime = (timestamp) => {
}
};
const hasResetTimestamp = (resetAt) => resetAt !== null && resetAt !== undefined && resetAt !== '';
export const calculateResetAfterSeconds = (resetAt) => {
if (!resetAt) return null;
if (!hasResetTimestamp(resetAt)) return null;
const resetAtTime = new Date(resetAt).getTime();
if (!Number.isFinite(resetAtTime)) return null;
const delta = Math.floor((resetAtTime - Date.now()) / 1000);
@@ -37,7 +39,7 @@ export const calculateResetAfterSeconds = (resetAt) => {
export const toUsageWindow = ({ usedPercent, windowSeconds, resetAt, valueLabel }) => {
const resetAfterSeconds = calculateResetAfterSeconds(resetAt);
const resetFormatted = resetAt ? formatResetTime(resetAt) : null;
const resetFormatted = hasResetTimestamp(resetAt) ? formatResetTime(resetAt) : null;
return {
usedPercent,
remainingPercent: usedPercent !== null ? Math.max(0, 100 - usedPercent) : null,