chore: Use valid license SPDX id. Revert logic refactor.
All checks were successful
CI / check (pull_request) Successful in 28m11s
CI / test (pull_request) Successful in 5m58s
CI / audit (pull_request) Successful in 20s

This commit is contained in:
Austin Schaefer 2026-08-21 14:03:10 +02:00
parent 6fc33f4854
commit 6445f32f8a
2 changed files with 11 additions and 18 deletions

View file

@ -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"] }

View file

@ -93,16 +93,15 @@ pub fn engagement_score(
return 0.0;
}
let mut score = match opened {
true => {
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);
}
}