Add missing shift type check
This commit is contained in:
@@ -67,15 +67,17 @@ impl Scheduler {
|
||||
}
|
||||
|
||||
/// Return all valid residents for the current slot
|
||||
pub fn valid_residents(&self, slot: Slot, schedule: &MonthlySchedule) -> Vec<ResidentId> {
|
||||
let other_slot_resident_id = schedule.get_resident_id(&slot.other_position());
|
||||
pub fn valid_residents(&self, slot: Slot, schedule: &MonthlySchedule) -> Vec<&ResidentId> {
|
||||
let required_type = slot.shift_type(); // Calculate once here
|
||||
let other_resident = schedule.get_resident_id(&slot.other_position());
|
||||
|
||||
self.config
|
||||
.residents
|
||||
.iter()
|
||||
.filter(|r| Some(&r.id) != other_slot_resident_id)
|
||||
.filter(|r| Some(&r.id) != other_resident)
|
||||
.filter(|r| !r.negative_shifts.contains(&slot.day))
|
||||
.map(|r| r.id.clone())
|
||||
.filter(|r| r.allowed_types.contains(&required_type))
|
||||
.map(|r| &r.id)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user