Fix open ticket pagination and CSAT fallback
This commit is contained in:
parent
1ba1f4a63c
commit
f9a72c8154
1 changed files with 12 additions and 19 deletions
|
|
@ -134,25 +134,18 @@ export async function fetchOpenScopedTickets(
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
|
|
||||||
for (const status of statuses) {
|
for (const status of statuses) {
|
||||||
await paginateTickets(
|
const snapshot = await ctx.db
|
||||||
() =>
|
.query("tickets")
|
||||||
ctx.db
|
.withIndex("by_tenant_status", (q) => q.eq("tenantId", tenantId).eq("status", status))
|
||||||
.query("tickets")
|
.collect();
|
||||||
.withIndex("by_tenant_status", (q) => q.eq("tenantId", tenantId).eq("status", status))
|
for (const ticket of snapshot) {
|
||||||
.order("desc"),
|
if (!OPEN_STATUSES.has(normalizeStatus(ticket.status))) continue;
|
||||||
(ticket) => {
|
if (scopedCompanyId && ticket.companyId !== scopedCompanyId) continue;
|
||||||
if (scopedCompanyId && ticket.companyId !== scopedCompanyId) {
|
const key = String(ticket._id);
|
||||||
return;
|
if (seen.has(key)) continue;
|
||||||
}
|
seen.add(key);
|
||||||
if (!OPEN_STATUSES.has(normalizeStatus(ticket.status))) {
|
results.push(ticket);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
const key = String(ticket._id);
|
|
||||||
if (seen.has(key)) return;
|
|
||||||
seen.add(key);
|
|
||||||
results.push(ticket);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue