fix(api): skip unknown release size score
ci / rust (pull_request) Successful in 1m31s
ci / web (pull_request) Successful in 39s
e2e / e2e (pull_request) Successful in 1m40s

This commit is contained in:
Miguel Palhas
2026-08-22 21:50:58 +01:00
parent cd9e22e410
commit 68e404ed07
+55 -2
View File
@@ -490,8 +490,12 @@ fn classify(
Candidate::PreGrab(&parsed),
release.size.unwrap_or_default(),
release.seeders.unwrap_or_default(),
)
.total;
);
let score = if release.size.is_some() {
score.total
} else {
score.source.saturating_add(score.seeders)
};
Ok(ClassifiedRelease {
indexer_id: release.indexer_id,
guid: release.guid,
@@ -765,6 +769,55 @@ mod tests {
);
}
#[test]
fn releases_without_sizes_skip_the_size_score() {
let policy = Policy {
id: PolicyId(1),
name: "test".into(),
required_audio: RequiredAudio::OriginalLanguage,
dub_blacklist: Vec::new(),
hdr_rules: HdrRules {
rejected_dolby_vision_profiles: Vec::new(),
},
size_bands: std::collections::BTreeMap::from([(
Resolution::R2160p,
SizeBand {
floor_bytes: gib(8),
target_bytes: gib(22),
penalty_points_per_gib_over: 60,
},
)]),
resolution_preference: vec![Resolution::R2160p],
source_weights: std::collections::BTreeMap::from([(Source::WebDl, 2)]),
score_weights: ScoreWeights::default(),
};
let release = SearchRelease {
indexer_id: 1,
guid: "release".into(),
name: "Dune.Part.Two.2024.2160p.WEB-DL".into(),
size: None,
seeders: Some(8),
publish_date: None,
download_url: "https://tracker/release".into(),
};
let parsed = arr_parse::parse(&release.name);
let core_score = score(&policy, Candidate::PreGrab(&parsed), 0, 8);
let classified = classify(
release,
&policy,
&MovieOverrides::default(),
&Language::Other("en".into()),
)
.expect("classified release");
assert_eq!(
classified.score,
core_score.source.saturating_add(core_score.seeders)
);
assert_ne!(classified.score, core_score.total);
}
#[test]
fn manual_inputs_skip_title_upstreams() {
assert!(matches!(