From 56dd8d41d51959de4649aef83527257ea7bc597f Mon Sep 17 00:00:00 2001 From: Aapo Laakkio Date: Fri, 6 Dec 2024 15:43:52 +0200 Subject: [PATCH] Randomize ballot order when fetching them --- src/backend/routes/elections.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/routes/elections.ts b/src/backend/routes/elections.ts index af90df5..0b88487 100644 --- a/src/backend/routes/elections.ts +++ b/src/backend/routes/elections.ts @@ -18,7 +18,8 @@ export const findFinishedElectionWithVotes = async () => { ballots: { with: { votes: true - } + }, + orderBy: (_ballotsTable, { sql }) => sql`RANDOM()` // Randomize the order } } }) @@ -41,7 +42,8 @@ export const getCompletedElectionWithVotes = async (electionId: string) => { ballots: { with: { votes: true - } + }, + orderBy: (_ballotsTable, { sql }) => sql`RANDOM()` // Randomize the order } } })