From 88cc0553f6a3cc763fe52233950d286104180e23 Mon Sep 17 00:00:00 2001 From: Kenearos Date: Tue, 7 Jul 2026 11:45:15 +0200 Subject: [PATCH] refactor(variants): drop unused isWinner flag on variant results Each variant emitted isWinner:false and the calculator set winner.isWinner =true, but the UI marks the winner via variantId===winnerId, never the flag. Only one test read it. Removed from the 6 variant returns, the empty result, and the calculator. Co-Authored-By: Claude Opus 4.8 (1M context) --- calculator.js | 9 +++------ test-suite.js | 1 - variants.js | 18 ++++++------------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/calculator.js b/calculator.js index cfdaf8d..a4eff72 100644 --- a/calculator.js +++ b/calculator.js @@ -64,8 +64,6 @@ class BonusCalculator { winner = r; } } - winner.isWinner = true; - return { classified, isVacation, @@ -94,14 +92,13 @@ class BonusCalculator { threshold: null, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, - bonus: 0, - isWinner: false + bonus: 0 }; return { classified: { fr: 0, sa: 0, so: 0, weekday: 0 }, isVacation, - winner: { ...empty, isWinner: true }, - allResults: [1, 2, 3].map(variantId => ({ ...empty, variantId, isWinner: variantId === 1 })), + winner: { ...empty }, + allResults: [1, 2, 3].map(variantId => ({ ...empty, variantId })), totalBonus: 0 }; } diff --git a/test-suite.js b/test-suite.js index e1d0952..8caeabb 100644 --- a/test-suite.js +++ b/test-suite.js @@ -844,7 +844,6 @@ runner.test('Winner: klarer Sieger mit weekdays + 1 Fr', (t) => { { date: new Date('2025-11-04T12:00:00'), share: 1.0 } // Di ]; const result = calc.calculateMonthlyBonus(duties, false); - t.assertTrue(result.winner.isWinner, 'winner.isWinner=true'); t.assertEqual(result.allResults.length, 3, '3 Varianten im allResults'); t.assertTrue(result.totalBonus > 0, 'Bonus > 0'); }); diff --git a/variants.js b/variants.js index 10a0b67..a247a29 100644 --- a/variants.js +++ b/variants.js @@ -52,8 +52,7 @@ function variant1(classified, isVacation) { threshold: { frSo: frSoThreshold, weekday: weekdayThreshold }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, - bonus: 0, - isWinner: false + bonus: 0 }; } @@ -83,8 +82,7 @@ function variant1(classified, isVacation) { threshold: { frSo: frSoThreshold, weekday: weekdayThreshold }, deduction, paidShares, - bonus, - isWinner: false + bonus }; } @@ -104,8 +102,7 @@ function variant2(classified, isVacation) { threshold: { sa: saThreshold, weekday: weekdayThreshold }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, - bonus: 0, - isWinner: false + bonus: 0 }; } @@ -127,8 +124,7 @@ function variant2(classified, isVacation) { threshold: { sa: saThreshold, weekday: weekdayThreshold }, deduction, paidShares, - bonus, - isWinner: false + bonus }; } @@ -146,8 +142,7 @@ function variant3(classified, isVacation) { threshold: { pool: poolThreshold }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, - bonus: 0, - isWinner: false + bonus: 0 }; } @@ -177,8 +172,7 @@ function variant3(classified, isVacation) { threshold: { pool: poolThreshold }, deduction, paidShares, - bonus, - isWinner: false + bonus }; }