feat: add SLA category breakdown report

This commit is contained in:
Esdras Renan 2025-11-08 02:47:39 -03:00
parent 6ab8a6ce89
commit a62f3d5283
8 changed files with 231 additions and 10 deletions

View file

@ -6,6 +6,7 @@ type ReportsCtxOptions = {
tickets?: Doc<"tickets">[]
createdRangeTickets?: Doc<"tickets">[]
queues?: Doc<"queues">[]
categories?: Doc<"ticketCategories">[]
companies?: Map<string, Doc<"companies">>
users?: Map<string, Doc<"users">>
ticketEventsByTicket?: Map<string, Array<{ type: string; payload?: unknown; createdAt: number }>>
@ -38,6 +39,7 @@ export function createReportsCtx({
tickets = [],
createdRangeTickets = tickets,
queues = [],
categories = [],
companies = new Map<string, Doc<"companies">>(),
users = new Map<string, Doc<"users">>(),
ticketEventsByTicket = new Map<string, Array<{ type: string; payload?: unknown; createdAt: number }>>(),
@ -78,6 +80,18 @@ export function createReportsCtx({
}
}
if (table === "ticketCategories") {
return {
withIndex: vi.fn((_indexName: string, cb?: (builder: typeof noopIndexBuilder) => unknown) => {
cb?.(noopIndexBuilder)
return {
collect: vi.fn(async () => categories),
}
}),
collect: vi.fn(async () => categories),
}
}
if (table === "ticketEvents") {
return {
withIndex: vi.fn((_indexName: string, cb?: (builder: { eq: (field: unknown, value: unknown) => unknown }) => unknown) => {