Skip to content
Merged

test #47

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/api/src/services/vote.Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
Loading