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]
|
[workspace.package]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
license = "AGPL-3"
|
license = "AGPL-3.0-or-later"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
|
||||||
|
|
@ -93,16 +93,15 @@ pub fn engagement_score(
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut score = match opened {
|
let mut score = if !opened {
|
||||||
true => {
|
0.0
|
||||||
|
} else {
|
||||||
match (dwell_seconds, estimated_read_seconds) {
|
match (dwell_seconds, estimated_read_seconds) {
|
||||||
(Some(dwell), Some(est)) if est > 0 => (dwell as f64 / est as f64).min(1.0),
|
(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:
|
// Opened but we don't yet know dwell time / read-time estimate:
|
||||||
// credit partial engagement rather than 0 or 1.
|
// credit partial engagement rather than 0 or 1.
|
||||||
_ => 0.5,
|
_ => 0.5,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
false => 0.0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if starred {
|
if starred {
|
||||||
|
|
@ -366,19 +365,13 @@ mod tests {
|
||||||
/// 0.3 on top of the dwell-ratio score.
|
/// 0.3 on top of the dwell-ratio score.
|
||||||
#[test]
|
#[test]
|
||||||
fn engagement_score_starred_adds_bonus() {
|
fn engagement_score_starred_adds_bonus() {
|
||||||
assert_eq!(
|
assert_eq!(engagement_score(true, Some(30), Some(60), true, false), 0.8);
|
||||||
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 +0.3 star bonus must also respect the 1.0 ceiling, even when
|
||||||
/// the dwell ratio alone is already at the max.
|
/// the dwell ratio alone is already at the max.
|
||||||
#[test]
|
#[test]
|
||||||
fn engagement_score_starred_bonus_caps_at_one() {
|
fn engagement_score_starred_bonus_caps_at_one() {
|
||||||
assert_eq!(
|
assert_eq!(engagement_score(true, Some(60), Some(60), true, false), 1.0);
|
||||||
engagement_score(true, Some(60), Some(60), true, false),
|
|
||||||
1.0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue