Skip to content

Commit 82566cd

Browse files
committed
fix: prevent the system from saying "bonus points are being awarded" on canvas when no rankings have bonus points to award
1 parent bac2b98 commit 82566cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,19 @@ export const getUserRankingAcrossAllRankings = async function(prisma: PrismaClie
740740
};
741741

742742
export const bonusPointsAwardingStarted = async function(prisma: PrismaClient, atDateTime: Date = new Date()): Promise<{ started: boolean, startTime: Date | null }> {
743+
// Check if there are any rankings that award bonus points at all
744+
const rankingsAwardingBonusPointsCount = await prisma.codamCoalitionRanking.count({
745+
where: {
746+
bonus_points: {
747+
gt: 0,
748+
},
749+
},
750+
});
751+
if (rankingsAwardingBonusPointsCount === 0) {
752+
return { started: false, startTime: null };
753+
}
754+
755+
743756
// Calculate when the bonus points awarding will start (7 days prior to end of the bloc)
744757
const blocAtDate = await getBlocAtDate(prisma, atDateTime);
745758
const bonusPointsAwardingStartTime = blocAtDate ? new Date(blocAtDate.end_at.getTime() - 7 * 24 * 60 * 60 * 1000) : null;

0 commit comments

Comments
 (0)