From 393eee565d957a99232be7651523b6a53f6207f0 Mon Sep 17 00:00:00 2001 From: carlpinto25 Date: Sat, 28 Mar 2026 00:43:11 +0530 Subject: [PATCH] test --- apps/api/src/services/vote.Service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/vote.Service.ts b/apps/api/src/services/vote.Service.ts index 3fcea05..ec866a4 100644 --- a/apps/api/src/services/vote.Service.ts +++ b/apps/api/src/services/vote.Service.ts @@ -11,6 +11,7 @@ function isVotingOpen(): boolean { const year = istTime.getUTCFullYear(); const month = istTime.getUTCMonth() + 1; + const day = istTime.getUTCDate(); if (year !== 2026 || month !== 3) return false; @@ -37,6 +38,10 @@ export const submitVote = async ( userId: string, vote: VoteRequest ) => { + if (!isVotingOpen()) { + throw new Error('Voting is currently closed'); + } + const { stallId, rating } = vote const ormDb = getDb(env.DB) @@ -76,11 +81,11 @@ export const submitVote = async ( .select({ stallId: ratings.stallId }) .from(ratings) .where(eq(ratings.userId, userId)); - + const stallIds = userRatings .map(r => r.stallId) .filter((id): id is number => id !== null); - + await refreshStallAggregates(env.DB, stallIds); } else { // Normal vote (could be qualified or not, but only this stall is affected)