mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 04:33:42 +08:00
[questions][fix] fix pagination off by one (#425)
This commit is contained in:
@ -77,7 +77,6 @@ export const questionsQuestionEncounterRouter = createProtectedRouter()
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.mutation('update', {
|
.mutation('update', {
|
||||||
//
|
|
||||||
input: z.object({
|
input: z.object({
|
||||||
companyId: z.string().optional(),
|
companyId: z.string().optional(),
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
|
@ -14,7 +14,7 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|||||||
cursor: z
|
cursor: z
|
||||||
.object({
|
.object({
|
||||||
idCursor: z.string().optional(),
|
idCursor: z.string().optional(),
|
||||||
lastSeenCursor: z.date().optional(),
|
lastSeenCursor: z.date().nullish().optional(),
|
||||||
upvoteCursor: z.number().optional(),
|
upvoteCursor: z.number().optional(),
|
||||||
})
|
})
|
||||||
.nullish(),
|
.nullish(),
|
||||||
@ -49,8 +49,6 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const toSkip = cursor ? 1 : 0;
|
|
||||||
|
|
||||||
const questionsData = await ctx.prisma.questionsQuestion.findMany({
|
const questionsData = await ctx.prisma.questionsQuestion.findMany({
|
||||||
cursor:
|
cursor:
|
||||||
cursor !== undefined
|
cursor !== undefined
|
||||||
@ -81,7 +79,6 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|||||||
votes: true,
|
votes: true,
|
||||||
},
|
},
|
||||||
orderBy: sortCondition,
|
orderBy: sortCondition,
|
||||||
skip: toSkip,
|
|
||||||
take: input.limit + 1,
|
take: input.limit + 1,
|
||||||
where: {
|
where: {
|
||||||
...(input.questionTypes.length > 0
|
...(input.questionTypes.length > 0
|
||||||
|
Reference in New Issue
Block a user