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) <noreply@anthropic.com>
This commit is contained in:
Kenearos 2026-07-07 11:45:15 +02:00
parent cb46e8fb04
commit 88cc0553f6
3 changed files with 9 additions and 19 deletions

View file

@ -64,8 +64,6 @@ class BonusCalculator {
winner = r; winner = r;
} }
} }
winner.isWinner = true;
return { return {
classified, classified,
isVacation, isVacation,
@ -94,14 +92,13 @@ class BonusCalculator {
threshold: null, threshold: null,
deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 },
paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 },
bonus: 0, bonus: 0
isWinner: false
}; };
return { return {
classified: { fr: 0, sa: 0, so: 0, weekday: 0 }, classified: { fr: 0, sa: 0, so: 0, weekday: 0 },
isVacation, isVacation,
winner: { ...empty, isWinner: true }, winner: { ...empty },
allResults: [1, 2, 3].map(variantId => ({ ...empty, variantId, isWinner: variantId === 1 })), allResults: [1, 2, 3].map(variantId => ({ ...empty, variantId })),
totalBonus: 0 totalBonus: 0
}; };
} }

View file

@ -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 { date: new Date('2025-11-04T12:00:00'), share: 1.0 } // Di
]; ];
const result = calc.calculateMonthlyBonus(duties, false); 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.assertEqual(result.allResults.length, 3, '3 Varianten im allResults');
t.assertTrue(result.totalBonus > 0, 'Bonus > 0'); t.assertTrue(result.totalBonus > 0, 'Bonus > 0');
}); });

View file

@ -52,8 +52,7 @@ function variant1(classified, isVacation) {
threshold: { frSo: frSoThreshold, weekday: weekdayThreshold }, threshold: { frSo: frSoThreshold, weekday: weekdayThreshold },
deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 },
paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 },
bonus: 0, bonus: 0
isWinner: false
}; };
} }
@ -83,8 +82,7 @@ function variant1(classified, isVacation) {
threshold: { frSo: frSoThreshold, weekday: weekdayThreshold }, threshold: { frSo: frSoThreshold, weekday: weekdayThreshold },
deduction, deduction,
paidShares, paidShares,
bonus, bonus
isWinner: false
}; };
} }
@ -104,8 +102,7 @@ function variant2(classified, isVacation) {
threshold: { sa: saThreshold, weekday: weekdayThreshold }, threshold: { sa: saThreshold, weekday: weekdayThreshold },
deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 },
paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 },
bonus: 0, bonus: 0
isWinner: false
}; };
} }
@ -127,8 +124,7 @@ function variant2(classified, isVacation) {
threshold: { sa: saThreshold, weekday: weekdayThreshold }, threshold: { sa: saThreshold, weekday: weekdayThreshold },
deduction, deduction,
paidShares, paidShares,
bonus, bonus
isWinner: false
}; };
} }
@ -146,8 +142,7 @@ function variant3(classified, isVacation) {
threshold: { pool: poolThreshold }, threshold: { pool: poolThreshold },
deduction: { fr: 0, sa: 0, so: 0, weekday: 0 }, deduction: { fr: 0, sa: 0, so: 0, weekday: 0 },
paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 }, paidShares: { fr: 0, sa: 0, so: 0, weekday: 0 },
bonus: 0, bonus: 0
isWinner: false
}; };
} }
@ -177,8 +172,7 @@ function variant3(classified, isVacation) {
threshold: { pool: poolThreshold }, threshold: { pool: poolThreshold },
deduction, deduction,
paidShares, paidShares,
bonus, bonus
isWinner: false
}; };
} }