diff --git a/Cargo.toml b/Cargo.toml index 355f5a3..1dc5e8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ [workspace.package] edition = "2021" version = "0.1.0" -license = "AGPL-3" +license = "AGPL-3.0-or-later" [workspace.dependencies] tokio = { version = "1", features = ["full"] } diff --git a/crates/core/src/affinity.rs b/crates/core/src/affinity.rs index 1ac906b..e7aaf77 100644 --- a/crates/core/src/affinity.rs +++ b/crates/core/src/affinity.rs @@ -93,16 +93,15 @@ pub fn engagement_score( return 0.0; } - let mut score = match opened { - true => { - match (dwell_seconds, estimated_read_seconds) { - (Some(dwell), Some(est)) if est > 0 => (dwell as f64 / est as f64).min(1.0), - // Opened but we don't yet know dwell time / read-time estimate: - // credit partial engagement rather than 0 or 1. - _ => 0.5, - } + let mut score = if !opened { + 0.0 + } else { + match (dwell_seconds, estimated_read_seconds) { + (Some(dwell), Some(est)) if est > 0 => (dwell as f64 / est as f64).min(1.0), + // Opened but we don't yet know dwell time / read-time estimate: + // credit partial engagement rather than 0 or 1. + _ => 0.5, } - false => 0.0 }; if starred { @@ -366,19 +365,13 @@ mod tests { /// 0.3 on top of the dwell-ratio score. #[test] fn engagement_score_starred_adds_bonus() { - assert_eq!( - engagement_score(true, Some(30), Some(60), true, false), - 0.8 - ); + assert_eq!(engagement_score(true, Some(30), Some(60), true, false), 0.8); } /// The +0.3 star bonus must also respect the 1.0 ceiling, even when /// the dwell ratio alone is already at the max. #[test] fn engagement_score_starred_bonus_caps_at_one() { - assert_eq!( - engagement_score(true, Some(60), Some(60), true, false), - 1.0 - ); + assert_eq!(engagement_score(true, Some(60), Some(60), true, false), 1.0); } }