File size: 1,160 Bytes
b7e7f16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use chrono::Timelike;

use crate::domain::{Employee, Shift};

use super::coverage::{candidate_redundancy_is_valid, public_candidate_counts};

/// Verifies that the exact public dataset we will ship still matches generator goals.
pub(super) fn validate_public_dataset(employees: &[Employee], shifts: &[Shift]) {
    let counts = public_candidate_counts(employees, shifts);
    let min_count = counts.iter().copied().min().unwrap_or(0);
    let three_plus = counts.iter().filter(|&&count| count >= 3).count();
    let weakest: Vec<String> = shifts
        .iter()
        .zip(counts.iter())
        .filter(|(_, &count)| count == min_count)
        .take(5)
        .map(|(shift, &count)| {
            format!(
                "{} {} {} -> {}",
                shift.location,
                shift.start.time().hour(),
                shift.required_skill,
                count
            )
        })
        .collect();
    assert!(
        candidate_redundancy_is_valid(employees, shifts),
        "public dataset should maintain candidate redundancy; min_count={min_count}, three_plus={three_plus}/{} weakest={weakest:?}",
        counts.len()
    );
}