feat(algo): skip day when candidates < slotsPerDay

This commit is contained in:
ferdi2go committed 2026-04-28 10:07:22 +00:00
1 parent 625f9c7037
commit 3d314e84fd
2 files changed
+39 -3

No files matched your search

+6 -3
View File
@@ -86,14 +86,17 @@ export function generatePlan(workdays, employees, history, randomFn = Math.rando
const candidates = employees.filter(e =>
isEligible(e, date, monthAssignments, history)
);
if (candidates.length === 0) continue;
if (candidates.length < slotsPerDay) {
skippedDates.push(date);
continue;
}
const scored = candidates
.map(e => ({ employee: e, score: scoreCandidate(e, date, history, randomFn) }))
.sort((a, b) => b.score - a.score);
const take = Math.min(slotsPerDay, scored.length);
for (let i = 0; i < take; i++) {
for (let i = 0; i < slotsPerDay; i++) {
monthAssignments.push({ date, employeeId: scored[i].employee.id, manual: false });
}
}