Skip to content

Commit 30dbc89

Browse files
committed
update pollsParticipatedCount and participantCount on setVote
1 parent 641d1cf commit 30dbc89

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/user/user.service.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,30 @@ export class UserService {
243243
type: ActionType.VOTED,
244244
},
245245
});
246+
const pollsParticipatedCount = await prisma.userAction.count({
247+
where: {
248+
userId: user.id,
249+
type: ActionType.VOTED,
250+
},
251+
});
252+
const participantCount = await prisma.userAction.count({
253+
where: {
254+
pollId: dto.pollId,
255+
type: ActionType.VOTED,
256+
},
257+
});
258+
await prisma.user.update({
259+
where: { worldID: dto.worldID },
260+
data: {
261+
pollsParticipatedCount,
262+
},
263+
});
264+
await prisma.poll.update({
265+
where: { pollId: dto.pollId },
266+
data: {
267+
participantCount,
268+
},
269+
});
246270
return {
247271
voteID: vote.voteID,
248272
actionId: action.id,

0 commit comments

Comments
 (0)