From c118ed59d490e9cc6dc66650d695b5059c80a10a Mon Sep 17 00:00:00 2001 From: hpkoh <53825802+hpkoh@users.noreply.github.com> Date: Mon, 24 Oct 2022 23:20:51 +0800 Subject: [PATCH] [questions][fix] fix pagination off by one (#425) --- .../src/server/router/questions-question-encounter-router.ts | 1 - apps/portal/src/server/router/questions-question-router.ts | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/portal/src/server/router/questions-question-encounter-router.ts b/apps/portal/src/server/router/questions-question-encounter-router.ts index 0f597ad3..8fa4a0e4 100644 --- a/apps/portal/src/server/router/questions-question-encounter-router.ts +++ b/apps/portal/src/server/router/questions-question-encounter-router.ts @@ -77,7 +77,6 @@ export const questionsQuestionEncounterRouter = createProtectedRouter() }, }) .mutation('update', { - // input: z.object({ companyId: z.string().optional(), id: z.string(), diff --git a/apps/portal/src/server/router/questions-question-router.ts b/apps/portal/src/server/router/questions-question-router.ts index 3c4f8f8b..3ea33bce 100644 --- a/apps/portal/src/server/router/questions-question-router.ts +++ b/apps/portal/src/server/router/questions-question-router.ts @@ -14,7 +14,7 @@ export const questionsQuestionRouter = createProtectedRouter() cursor: z .object({ idCursor: z.string().optional(), - lastSeenCursor: z.date().optional(), + lastSeenCursor: z.date().nullish().optional(), upvoteCursor: z.number().optional(), }) .nullish(), @@ -49,8 +49,6 @@ export const questionsQuestionRouter = createProtectedRouter() }, ]; - const toSkip = cursor ? 1 : 0; - const questionsData = await ctx.prisma.questionsQuestion.findMany({ cursor: cursor !== undefined @@ -81,7 +79,6 @@ export const questionsQuestionRouter = createProtectedRouter() votes: true, }, orderBy: sortCondition, - skip: toSkip, take: input.limit + 1, where: { ...(input.questionTypes.length > 0