feat(results): 🛂 Limit incomplete submissions
This commit is contained in:
@ -2,6 +2,7 @@ import { User } from 'db'
|
||||
import prisma from 'libs/prisma'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getSession } from 'next-auth/react'
|
||||
import { isFreePlan } from 'services/user'
|
||||
import { methodNotAllowed } from 'utils'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
@ -27,6 +28,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
typebotId,
|
||||
typebot: { ownerId: user.id },
|
||||
answers: { some: {} },
|
||||
isCompleted: isFreePlan(user),
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'desc',
|
||||
|
@ -38,7 +38,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const stats: Stats = {
|
||||
totalViews,
|
||||
totalStarts,
|
||||
completionRate: Math.round((totalCompleted / totalStarts) * 100),
|
||||
totalCompleted,
|
||||
}
|
||||
return res.status(200).send({ stats })
|
||||
}
|
||||
|
Reference in New Issue
Block a user