Skip to content

Commit

Permalink
fix: only update scores negatively when diff < -10
Browse files Browse the repository at this point in the history
  • Loading branch information
FreekBes committed Jan 28, 2025
1 parent 9051c26 commit d7b0714
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handlers/points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...`);
Expand Down

0 comments on commit d7b0714

Please sign in to comment.