Skip to content

Commit c0e3a70

Browse files
committed
feat(shared): add volume series to AdminOverviewDTO
1 parent 16d4fd0 commit c0e3a70

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

packages/shared/src/admin.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { describe, expect, test } from "bun:test"
2+
import { AdminOverviewDTO } from "./admin"
3+
4+
const base = {
5+
counts: {
6+
total: 0,
7+
byStatus: { open: 0, in_progress: 0, resolved: 0, closed: 0 },
8+
byPriority: { low: 0, normal: 0, high: 0, urgent: 0 },
9+
last7Days: 0,
10+
},
11+
projects: { total: 0, withGithub: 0 },
12+
recentReports: [],
13+
recentEvents: [],
14+
perProject: [],
15+
}
16+
17+
describe("AdminOverviewDTO.volume", () => {
18+
test("accepts a zero-filled volume series", () => {
19+
const parsed = AdminOverviewDTO.parse({
20+
...base,
21+
volume: [
22+
{ date: "2026-05-18", count: 3 },
23+
{ date: "2026-05-19", count: 0 },
24+
],
25+
})
26+
expect(parsed.volume).toEqual([
27+
{ date: "2026-05-18", count: 3 },
28+
{ date: "2026-05-19", count: 0 },
29+
])
30+
})
31+
32+
test("rejects a payload missing volume", () => {
33+
expect(() => AdminOverviewDTO.parse(base)).toThrow()
34+
})
35+
36+
test("rejects a non-integer count", () => {
37+
expect(() =>
38+
AdminOverviewDTO.parse({ ...base, volume: [{ date: "2026-05-19", count: 1.5 }] }),
39+
).toThrow()
40+
})
41+
})

packages/shared/src/admin.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@ export const AdminOverviewDTO = z.object({
6060
recentReports: z.array(AdminRecentReportDTO),
6161
recentEvents: z.array(AdminRecentEventDTO),
6262
perProject: z.array(AdminProjectBreakdownDTO),
63+
// Zero-filled daily report counts for the trend chart. Ordered oldest →
64+
// newest; every UTC day in the trailing window is present (gaps = 0).
65+
// `date` is a `YYYY-MM-DD` UTC day string.
66+
volume: z.array(
67+
z.object({
68+
date: z.string(),
69+
count: z.number().int(),
70+
}),
71+
),
6372
})
6473
export type AdminOverviewDTO = z.infer<typeof AdminOverviewDTO>

0 commit comments

Comments
 (0)