From d7b0714b77cba31681bbd2f6dddecbcc8a0f8fe9 Mon Sep 17 00:00:00 2001 From: Freek Bes Date: Tue, 28 Jan 2025 18:14:01 +0100 Subject: [PATCH] fix: only update scores negatively when diff < -10 --- src/handlers/points.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/points.ts b/src/handlers/points.ts index ce518fb..3a87667 100644 --- a/src/handlers/points.ts +++ b/src/handlers/points.ts @@ -145,8 +145,8 @@ export const handleFixedPointScore = async function(prisma: PrismaClient, type: // Score(s) were already given for this type and typeIntraId in the past. // Calculate the point difference and hand out the difference as a new score. const pointDifference = Math.floor(Math.floor(points) - existingScores._sum.amount); - if (pointDifference == 0) { - console.log(`Score(s) already exist for type ${type.type} and typeIntraId ${typeIntraId}. Point difference is 0, no need to create a new score.`); + if (pointDifference < -10 ) { + console.log(`Score(s) already exist for type ${type.type} and typeIntraId ${typeIntraId}. Point difference is (close to) 0, no need to create a new score.`); return null; // No difference in points, no need to create a new score } console.log(`Score(s) already exist for type ${type.type} and typeIntraId ${typeIntraId}. Point difference is ${pointDifference}, handing out the difference as a new score...`);