🐛 Fix gateway timeout when poll has 55 options (#1238)

This commit is contained in:
Luke Vella 2024-08-03 12:54:28 +01:00 committed by GitHub
parent 0daa9dc494
commit 02f7c3ac06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 58 additions and 54 deletions

View file

@ -91,22 +91,26 @@ export const participants = router({
throw new TRPCError({ code: "BAD_REQUEST", message: "Poll not found" });
}
const participant = await prisma.participant.create({
data: {
pollId: pollId,
name: name,
email,
userId: user.id,
votes: {
createMany: {
data: votes.map(({ optionId, type }) => ({
optionId,
type,
pollId: pollId,
})),
},
const participant = await prisma.$transaction(async (prisma) => {
const participant = await prisma.participant.create({
data: {
pollId: pollId,
name: name,
email,
userId: user.id,
},
},
});
await prisma.vote.createMany({
data: votes.map(({ optionId, type }) => ({
optionId,
type,
pollId,
participantId: participant.id,
})),
});
return participant;
});
const emailsToSend: Promise<void>[] = [];