From 5a1cf999b6b9f150ae49fd55f92c61cfc9c72b4a Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Sat, 22 Aug 2026 21:31:45 +0100 Subject: [PATCH] fix(api): adapt search to arr-core scoring API PRs #63 and #65 were each green pre-merge but changed and consumed the same arr-core surface; merging both broke main. Size bands are now gibibytes with a points penalty, evaluate takes size_bytes, and Policy carries score_weights (column wiring tracked in #68). Co-Authored-By: Claude Fable 5 --- crates/arr-api/src/search.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/arr-api/src/search.rs b/crates/arr-api/src/search.rs index 0b3ecad..36cf87f 100644 --- a/crates/arr-api/src/search.rs +++ b/crates/arr-api/src/search.rs @@ -4,7 +4,7 @@ use std::time::UNIX_EPOCH; use arr_core::policy::{evaluate, Candidate}; use arr_core::{ DolbyVisionProfile, HdrRules, Language, MovieOverrides, Policy, PolicyId, RequiredAudio, - Resolution, Rule, SizeBand, Source, Verdict, + Resolution, Rule, ScoreWeights, SizeBand, Source, Verdict, }; use arr_indexer::{ProwlarrClient, SearchRelease, SearchRequest}; use axum::extract::{Query, State}; @@ -97,8 +97,9 @@ struct HdrRulesJson { #[derive(Debug, Deserialize)] struct SizeBandJson { - floor_gb: u64, - target_gb: u64, + floor_gib: u64, + target_gib: u64, + penalty_points_per_gib_over: i32, } #[derive(Debug, Deserialize)] @@ -434,8 +435,9 @@ fn policy_from_row(row: PolicyRow) -> Result { ( resolution, SizeBand { - floor_bytes: gb(band.floor_gb), - target_bytes: gb(band.target_gb), + floor_bytes: gib(band.floor_gib), + target_bytes: gib(band.target_gib), + penalty_points_per_gib_over: band.penalty_points_per_gib_over, }, ) }) @@ -449,6 +451,9 @@ fn policy_from_row(row: PolicyRow) -> Result { .into_iter() .filter_map(|(source, weight)| source_value(&source).map(|source| (source, weight))) .collect(), + // The row's score_weights column is not selected here yet; the seeded + // values match these defaults. Wiring the column through is #68. + score_weights: ScoreWeights::default(), }) } @@ -464,6 +469,7 @@ fn classify( overrides, original_language, Candidate::PreGrab(&parsed), + release.size, ); let (verdict, rule) = verdict(&evaluation.verdict); let score = score(policy, &parsed, release.size, release.seeders); @@ -555,8 +561,8 @@ fn bucket(verdict: &str) -> u8 { _ => 2, } } -fn gb(value: u64) -> u64 { - value.saturating_mul(1_000_000_000) +fn gib(value: u64) -> u64 { + value.saturating_mul(1024 * 1024 * 1024) } fn language(value: &str) -> Language { match value {