Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Filter deleted options from votes (#1619)
Luke Vellaebe265ddc3ae
diff --git a/apps/web/src/trpc/routers/polls/participants.ts b/apps/web/src/trpc/routers/polls/participants.tsindex d1c571ede..aec79bf08 100644--- a/apps/web/src/trpc/routers/polls/participants.ts+++ b/apps/web/src/trpc/routers/polls/participants.ts@@ -173,8 +173,23 @@ export const participants = router({},});+ const options = await prisma.option.findMany({+ where: {+ pollId,+ },+ select: {+ id: true,+ },+ });++ const existingOptionIds = new Set(options.map((option) => option.id));++ const validVotes = votes.filter(({ optionId }) =>+ existingOptionIds.has(optionId),+ );+await prisma.vote.createMany({- data: votes.map(({ optionId, type }) => ({+ data: validVotes.map(({ optionId, type }) => ({optionId,type,pollId,@@ -252,9 +267,24 @@ export const participants = router({},});+ const options = await prisma.option.findMany({+ where: {+ pollId,+ },+ select: {+ id: true,+ },+ });++ const existingOptionIds = new Set(options.map((option) => option.id));++ const validVotes = votes.filter(({ optionId }) =>+ existingOptionIds.has(optionId),+ );+// Create new votesawait tx.vote.createMany({- data: votes.map(({ optionId, type }) => ({+ data: validVotes.map(({ optionId, type }) => ({optionId,type,pollId,