mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-11 14:12:58 +00:00
fix(ui): ignore invalid usage export timestamps
This commit is contained in:
19
ui/src/ui/views/usage-query.test.ts
Normal file
19
ui/src/ui/views/usage-query.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildSessionsCsv } from "./usage-query.ts";
|
||||
import type { UsageSessionEntry } from "./usageTypes.ts";
|
||||
|
||||
describe("usage query CSV export", () => {
|
||||
it("omits invalid session updated timestamps instead of throwing", () => {
|
||||
const csv = buildSessionsCsv([
|
||||
{
|
||||
key: "session-1",
|
||||
label: "Session 1",
|
||||
updatedAt: Number.POSITIVE_INFINITY,
|
||||
usage: null,
|
||||
} satisfies UsageSessionEntry,
|
||||
]);
|
||||
|
||||
expect(csv).toContain("session-1,Session 1,,,,,,,,,,,,,,,");
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { timestampMsToIsoString } from "../../../../src/shared/number-coercion.js";
|
||||
import { normalizeLowercaseStringOrEmpty, uniqueStrings } from "../string-coerce.ts";
|
||||
import { extractQueryTerms } from "../usage-helpers.ts";
|
||||
import type { CostDailyEntry, UsageAggregates, UsageSessionEntry } from "./usageTypes.ts";
|
||||
@@ -63,7 +64,7 @@ const buildSessionsCsv = (sessions: UsageSessionEntry[]): string => {
|
||||
session.channel ?? "",
|
||||
session.modelProvider ?? session.providerOverride ?? "",
|
||||
session.model ?? session.modelOverride ?? "",
|
||||
session.updatedAt ? new Date(session.updatedAt).toISOString() : "",
|
||||
timestampMsToIsoString(session.updatedAt) ?? "",
|
||||
usage?.durationMs ?? "",
|
||||
usage?.messageCounts?.total ?? "",
|
||||
usage?.messageCounts?.errors ?? "",
|
||||
|
||||
Reference in New Issue
Block a user