Fix easy days causing load balancer to disproportionately schedule graduates to the furthest day (#3643)

* don't do easy days calculation if all days are the same ease
This commit is contained in:
Jake Probst 2024-12-18 04:49:59 -08:00 committed by GitHub
parent 482874d4f0
commit 69e699dc13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -219,12 +219,23 @@ impl LoadBalancer {
)
})
.unzip();
let easy_days_percentages = self.easy_days_percentages_by_preset.get(&deckconfig_id)?;
let percentages = weekdays
// check if easy days are in effect by seeing if all days have the same
// configuration. If all days are the same, we can skip out on calculating
// the distribution
let easy_days_are_all_the_same = easy_days_percentages
.iter()
.map(|&wd| easy_days_percentages[wd])
.collect::<Vec<_>>();
let expected_distribution = check_review_distribution(&review_counts, &percentages);
.all(|day| easy_days_percentages[0] == *day);
let expected_distribution = if easy_days_are_all_the_same {
vec![1.0; weekdays.len()]
} else {
let percentages = weekdays
.iter()
.map(|&wd| easy_days_percentages[wd])
.collect::<Vec<_>>();
check_review_distribution(&review_counts, &percentages)
};
// calculate params for each day
let intervals_and_params = interval_days