Change ResidentId(String) to ResidentId(u8), impl Copy for ShiftType, use u8 for all UserConfig params
This commit is contained in:
@@ -27,7 +27,7 @@ impl Scheduler {
|
||||
pub fn run(&self, schedule: &mut MonthlySchedule, tracker: &mut WorkloadTracker) -> bool {
|
||||
schedule.prefill(&self.config);
|
||||
for (slot, res_id) in schedule.0.iter() {
|
||||
tracker.insert(res_id, &self.config, *slot);
|
||||
tracker.insert(*res_id, &self.config, *slot);
|
||||
}
|
||||
|
||||
self.search(schedule, tracker, Slot::default())
|
||||
@@ -64,7 +64,7 @@ impl Scheduler {
|
||||
(workload, (tie_breaker * 1000.0) as usize)
|
||||
});
|
||||
|
||||
for id in &valid_resident_ids {
|
||||
for id in valid_resident_ids {
|
||||
schedule.insert(slot, id);
|
||||
tracker.insert(id, &self.config, slot);
|
||||
|
||||
@@ -80,7 +80,7 @@ impl Scheduler {
|
||||
}
|
||||
|
||||
/// Return all valid residents for the current slot
|
||||
pub fn valid_residents(&self, slot: Slot, schedule: &MonthlySchedule) -> Vec<&ResidentId> {
|
||||
pub fn valid_residents(&self, slot: Slot, schedule: &MonthlySchedule) -> Vec<ResidentId> {
|
||||
let required_type = slot.shift_type();
|
||||
let other_resident = slot
|
||||
.other_position()
|
||||
@@ -94,7 +94,7 @@ impl Scheduler {
|
||||
&& !r.negative_shifts.contains(&slot.day)
|
||||
&& r.allowed_types.contains(&required_type)
|
||||
})
|
||||
.map(|r| &r.id)
|
||||
.map(|r| r.id)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -120,12 +120,12 @@ mod tests {
|
||||
#[fixture]
|
||||
fn config() -> UserConfig {
|
||||
UserConfig::default().with_residents(vec![
|
||||
Resident::new("1", "Stefanos"),
|
||||
Resident::new("2", "Iordanis"),
|
||||
Resident::new("3", "Maria"),
|
||||
Resident::new("4", "Veatriki"),
|
||||
Resident::new("5", "Takis"),
|
||||
Resident::new("6", "Akis"),
|
||||
Resident::new(1, "Stefanos"),
|
||||
Resident::new(2, "Iordanis"),
|
||||
Resident::new(3, "Maria"),
|
||||
Resident::new(4, "Veatriki"),
|
||||
Resident::new(5, "Takis"),
|
||||
Resident::new(6, "Akis"),
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user