fix(api): adapt search to arr-core scoring API
ci / web (push) Successful in 31s
ci / rust (push) Successful in 2m36s
e2e / e2e (push) Successful in 2m41s

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 <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-08-22 21:31:45 +01:00
parent e9c055675b
commit 5a1cf999b6
+13 -7
View File
@@ -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<Policy, ApiError> {
(
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<Policy, ApiError> {
.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 {