fix(api): specials stay out of episode counters

This commit is contained in:
Miguel Palhas
2026-08-23 16:40:38 +01:00
parent fc93d27f7e
commit 93ccea2de0
2 changed files with 17 additions and 8 deletions
+10 -1
View File
@@ -285,7 +285,16 @@ fn with_status(
episodes: &[arr_core::Episode],
now: SystemTime,
) -> Series {
let wanted = episodes.iter().filter(|episode| episode.wanted);
// §4.2: season 0 is invisible to status, so it stays out of the counters
// too. A series reading `complete` next to `42/52 eps` is the confusion
// this avoids. `UNIQUE (series_id, number)` means there is at most one.
let specials = seasons
.iter()
.find(|season| season.number == 0)
.map(|season| season.id);
let wanted = episodes
.iter()
.filter(|episode| episode.wanted && specials != Some(episode.season_id));
let available = wanted
.clone()
.filter(|episode| episode.state == MediaState::Available);
+7 -7
View File
@@ -1,7 +1,6 @@
use std::collections::HashSet;
use std::time::{Duration, SystemTime};
use crate::{Episode, MediaState, Season, SeasonId, Series};
use crate::{Episode, MediaState, Season, Series};
const AIRING_WINDOW: Duration = Duration::from_hours(14 * 24);
@@ -28,14 +27,15 @@ pub fn derive_series_status(
episodes: &[Episode],
now: SystemTime,
) -> SeriesStatus {
let specials: HashSet<SeasonId> = seasons
// A series has at most one season 0, so this is a comparison rather than
// a set: no allocation on a function the list view calls per series.
let specials = seasons
.iter()
.filter(|season| season.number == 0)
.map(|season| season.id)
.collect();
.find(|season| season.number == 0)
.map(|season| season.id);
let wanted = episodes
.iter()
.filter(|episode| episode.wanted && !specials.contains(&episode.season_id));
.filter(|episode| episode.wanted && specials != Some(episode.season_id));
let complete = wanted
.clone()
.all(|episode| episode.state == MediaState::Available);