Skip to content

Commit 9051c26

Browse files
committed
fix: score updates can cause -1 points
1 parent 581ab8a commit 9051c26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/handlers/points.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export const handleFixedPointScore = async function(prisma: PrismaClient, type:
144144
if (existingScores._sum.amount !== null) {
145145
// Score(s) were already given for this type and typeIntraId in the past.
146146
// Calculate the point difference and hand out the difference as a new score.
147-
const pointDifference = Math.floor(points - existingScores._sum.amount);
148-
if (pointDifference === 0) {
147+
const pointDifference = Math.floor(Math.floor(points) - existingScores._sum.amount);
148+
if (pointDifference == 0) {
149149
console.log(`Score(s) already exist for type ${type.type} and typeIntraId ${typeIntraId}. Point difference is 0, no need to create a new score.`);
150150
return null; // No difference in points, no need to create a new score
151151
}

0 commit comments

Comments
 (0)