Skip to content

Commit

Permalink
🐛 (results) Lower the max limit in getResults endpoint to avoid paylo…
Browse files Browse the repository at this point in the history
…ad size error

Closes #908
  • Loading branch information
baptisteArno committed Oct 17, 2023
1 parent 1cc4ccf commit 885dcec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions apps/builder/src/features/results/api/getResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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(),
})
)
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion apps/builder/src/features/results/hooks/useResultsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const useResultsQuery = ({
trpc.results.getResults.useInfiniteQuery(
{
typebotId,
limit: '50',
},
{
getNextPageParam: (lastPage) => lastPage.nextCursor,
Expand Down
8 changes: 5 additions & 3 deletions apps/docs/openapi/builder/_spec_.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
{
Expand Down

2 comments on commit 885dcec

@vercel
Copy link

@vercel vercel bot commented on 885dcec Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs.typebot.io
docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 885dcec Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.