2
0

🐛 (results) Lower the max limit in getResults endpoint to avoid payload size error

Closes #908
This commit is contained in:
Baptiste Arnaud
2023-10-17 14:19:09 +02:00
parent 1cc4ccfcfa
commit 885dcecd8d
4 changed files with 9 additions and 8 deletions

View File

@ -5,7 +5,7 @@ import { ResultWithAnswers, resultWithAnswersSchema } from '@typebot.io/schemas'
import { z } from 'zod'
import { isReadTypebotForbidden } from '@/features/typebot/helpers/isReadTypebotForbidden'
const maxLimit = 200
const maxLimit = 100
export const getResults = authenticatedProcedure
.meta({
@ -20,7 +20,7 @@ export const getResults = authenticatedProcedure
.input(
z.object({
typebotId: z.string(),
limit: z.string().regex(/^[0-9]{1,3}$/),
limit: z.coerce.number().min(1).max(maxLimit).default(50),
cursor: z.string().optional(),
})
)
@ -35,7 +35,7 @@ export const getResults = authenticatedProcedure
if (limit < 1 || limit > maxLimit)
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'limit must be between 1 and 200',
message: `limit must be between 1 and ${maxLimit}`,
})
const { cursor } = input
const typebot = await prisma.typebot.findUnique({

View File

@ -59,7 +59,7 @@ export const ExportAllResultsModal = ({ isOpen, onClose }: Props) => {
const { results, nextCursor } =
await trpcContext.results.getResults.fetch({
typebotId,
limit: '200',
limit: 100,
cursor,
})
allResults.push(...results)

View File

@ -11,7 +11,6 @@ export const useResultsQuery = ({
trpc.results.getResults.useInfiniteQuery(
{
typebotId,
limit: '50',
},
{
getNextPageParam: (lastPage) => lastPage.nextCursor,

View File

@ -29833,10 +29833,12 @@
{
"name": "limit",
"in": "query",
"required": true,
"required": false,
"schema": {
"type": "string",
"pattern": "^[0-9]{1,3}$"
"type": "number",
"minimum": 1,
"maximum": 100,
"default": 50
}
},
{