From f9a72c8154f6fa86293b434f5883c48ddeac71de Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Wed, 12 Nov 2025 22:24:31 -0300 Subject: [PATCH] Fix open ticket pagination and CSAT fallback --- convex/reports.ts | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/convex/reports.ts b/convex/reports.ts index fdb965c..aa0295a 100644 --- a/convex/reports.ts +++ b/convex/reports.ts @@ -134,25 +134,18 @@ export async function fetchOpenScopedTickets( const seen = new Set(); for (const status of statuses) { - await paginateTickets( - () => - ctx.db - .query("tickets") - .withIndex("by_tenant_status", (q) => q.eq("tenantId", tenantId).eq("status", status)) - .order("desc"), - (ticket) => { - if (scopedCompanyId && ticket.companyId !== scopedCompanyId) { - return; - } - if (!OPEN_STATUSES.has(normalizeStatus(ticket.status))) { - return; - } - const key = String(ticket._id); - if (seen.has(key)) return; - seen.add(key); - results.push(ticket); - }, - ); + const snapshot = await ctx.db + .query("tickets") + .withIndex("by_tenant_status", (q) => q.eq("tenantId", tenantId).eq("status", status)) + .collect(); + for (const ticket of snapshot) { + if (!OPEN_STATUSES.has(normalizeStatus(ticket.status))) continue; + if (scopedCompanyId && ticket.companyId !== scopedCompanyId) continue; + const key = String(ticket._id); + if (seen.has(key)) continue; + seen.add(key); + results.push(ticket); + } } return results;