Skip to content

Scheduling infrastructure for absolutely everyone.

Fix duplicated data returned by Prisma query in team availability view (#18416)

Cao Hoangd8027fe24875
diff --git a/packages/trpc/server/routers/viewer/availability/team/listTeamAvailability.handler.ts b/packages/trpc/server/routers/viewer/availability/team/listTeamAvailability.handler.ts
index 52d0a7413d8..cb60f939abe 100644
--- a/packages/trpc/server/routers/viewer/availability/team/listTeamAvailability.handler.ts
+++ b/packages/trpc/server/routers/viewer/availability/team/listTeamAvailability.handler.ts
@@ -67,9 +67,7 @@ async function getTeamMembers({
},
cursor: cursor ? { id: cursor } : undefined,
take: limit + 1, // We take +1 as itll be used for the next cursor
- orderBy: {
- id: "asc",
- },
+ orderBy: [{ userId: "asc" }, { id: "asc" }], // Prisma require a unique field for tie breaking duplicate value for pagination
distinct: ["userId"],
});