From 08755082fe89ea6be02119c427f5d1fa4cebbfee Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Wed, 6 Apr 2022 09:04:17 -0300 Subject: [PATCH] [FIX] NPS never finishing sending results (#25067) --- server/services/nps/sendNpsResults.ts | 2 +- server/services/nps/service.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server/services/nps/sendNpsResults.ts b/server/services/nps/sendNpsResults.ts index fc5212c7328..28448586559 100644 --- a/server/services/nps/sendNpsResults.ts +++ b/server/services/nps/sendNpsResults.ts @@ -8,7 +8,7 @@ import { SystemLogger } from '../../lib/logger/system'; type NPSResultPayload = { total: number; - votes: INpsVote[]; + votes: Pick[]; }; export const sendNpsResults = Meteor.bindEnvironment(function sendNpsResults(npsId: string, data: NPSResultPayload) { diff --git a/server/services/nps/service.ts b/server/services/nps/service.ts index be2c194e26c..b8bdca6f9fd 100644 --- a/server/services/nps/service.ts +++ b/server/services/nps/service.ts @@ -109,7 +109,6 @@ export class NPSService extends ServiceClassInternal implements INPSService { }, { projection: { - _id: 0, identifier: 1, roles: 1, score: 1, @@ -121,17 +120,24 @@ export class NPSService extends ServiceClassInternal implements INPSService { }), ); - const votes = sending.filter(Boolean) as INpsVote[]; + const votes = sending.filter(Boolean) as Pick[]; if (votes.length > 0) { const voteIds = votes.map(({ _id }) => _id); + const votesWithoutIds = votes.map(({ identifier, roles, score, comment }) => ({ + identifier, + roles, + score, + comment, + })); + const payload = { total, - votes, + votes: votesWithoutIds, }; sendNpsResults(nps._id, payload); - this.NpsVote.updateVotesToSent(voteIds); + await this.NpsVote.updateVotesToSent(voteIds); } const totalSent = await this.NpsVote.findByNpsIdAndStatus(nps._id, INpsVoteStatus.SENT).count();