refactor: generatePlan returns {assignments, skippedDates}
This commit is contained in:
1 parent
e4ae866375
commit
790ea72987
3 files changed
+16
-14
No files matched your search
+3
-2
@@ -76,9 +76,10 @@ function scoreCandidate(employee, isoDate, allHistory, randomFn) {
|
||||
return score;
|
||||
}
|
||||
|
||||
// Returns [{ date, employeeId, manual: false }] for each assigned workday
|
||||
// Returns { assignments: [{ date, employeeId, manual: false }], skippedDates: [] }
|
||||
export function generatePlan(workdays, employees, history, randomFn = Math.random) {
|
||||
const monthAssignments = [];
|
||||
const skippedDates = [];
|
||||
|
||||
for (const date of workdays) {
|
||||
const candidates = employees.filter(e =>
|
||||
@@ -93,5 +94,5 @@ export function generatePlan(workdays, employees, history, randomFn = Math.rando
|
||||
monthAssignments.push({ date, employeeId: scored[0].employee.id, manual: false });
|
||||
}
|
||||
|
||||
return monthAssignments;
|
||||
return { assignments: monthAssignments, skippedDates };
|
||||
}
|
||||
Reference in new issue
Block a user