chore: Use valid license SPDX id. Revert logic refactor.
This commit is contained in:
parent
6fc33f4854
commit
6445f32f8a
2 changed files with 11 additions and 18 deletions
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue