Skip to content

Commit

Permalink
Bypass queue system when uploading prior elections
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendPeter committed Feb 4, 2025
1 parent 980c429 commit 92982ac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/backend/src/Controllers/Ballot/castVoteController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,19 @@ async function uploadBallotsController(req: IElectionRequest, res: Response, nex
}))

try {
await (await EventQueue).publishBatch(castVoteEventQueue, events.filter(event => !('error' in event)));
// if it's a prior election bypass the queue system
// we're less concerned about race conditions for a prior election
if(targetElection.ballot_source == 'prior_election'){
await await Promise.all(
events.filter(event => !('error' in event)).map(event =>
// we only need to submit the ballot
// we don't need to update the roll since all the voter_auth fields are set to false
BallotModel.submitBallot(event.inputBallot, req, `Admin submits a ballot for prior election`)
)
)
}else{
await (await EventQueue).publishBatch(castVoteEventQueue, events.filter(event => !('error' in event)));
}
}catch(err: any){
const msg = `Could not upload ballots`;
Logger.error(req, `${msg}: ${err.message}`);
Expand Down

0 comments on commit 92982ac

Please sign in to comment.