Align usage stats to sliding windows

This commit is contained in:
YoVinchen
2025-12-31 17:00:53 +08:00
parent 52199f39c1
commit 6004084644
9 changed files with 141 additions and 177 deletions
+1 -7
View File
@@ -12,13 +12,7 @@ interface UsageSummaryCardsProps {
export function UsageSummaryCards({ days }: UsageSummaryCardsProps) {
const { t } = useTranslation();
const { startDate, endDate } = useMemo(() => {
const end = Math.floor(Date.now() / 1000);
const start = end - days * 24 * 60 * 60;
return { startDate: start, endDate: end };
}, [days]);
const { data: summary, isLoading } = useUsageSummary(startDate, endDate);
const { data: summary, isLoading } = useUsageSummary(days);
const stats = useMemo(() => {
const totalRequests = summary?.totalRequests ?? 0;