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;