Don't update entry if algorithm produces no score

This commit is contained in:
asonix 2023-03-31 18:02:50 -05:00
parent 11713b68c0
commit 3edffdf1dd

View file

@ -348,9 +348,13 @@ mod schema {
if let Some(now) = now {
Ok(mappings.iter().fold(HashMap::new(), |mut acc, mapping| {
for (document, score) in &mapping.value {
let entry = acc.entry(document.clone()).or_default();
let updated = the_algorithm(now, mapping.key, *score);
*entry += the_algorithm(now, mapping.key, *score);
if updated > 0_f64 {
let entry = acc.entry(document.clone()).or_default();
*entry += updated;
}
}
acc
}))