feat(db): add series, season and episode model #71

Merged
naps62-yolo merged 9 commits from issue/34-series-model into main 2026-08-22 22:04:28 +01:00
Showing only changes of commit 0cceea056a - Show all commits
+50
View File
@@ -21,6 +21,9 @@ macro_rules! id_type {
id_type!(RootId);
id_type!(PolicyId);
id_type!(MovieId);
id_type!(SeriesId);
id_type!(SeasonId);
id_type!(EpisodeId);
id_type!(MediaFileId);
id_type!(ReleaseId);
id_type!(GrabId);
@@ -183,6 +186,53 @@ pub struct Movie {
pub last_searched_at: Option<SystemTime>,
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct SeriesOverrides {
naps62-yolo marked this conversation as resolved Outdated
Outdated
Review

SeriesOverrides is field-for-field identical to MovieOverrides, but policy::evaluate takes &MovieOverrides (policy.rs:58, policy.rs:106). As written, a series cannot be evaluated against a policy without a conversion that does not exist yet, and the two structs will drift.

DESIGN §5.1 describes one override mechanism, not one per aggregate. Reuse a single type — rename MovieOverrides to TitleOverrides and drop this one.

`SeriesOverrides` is field-for-field identical to `MovieOverrides`, but `policy::evaluate` takes `&MovieOverrides` (`policy.rs:58`, `policy.rs:106`). As written, a series cannot be evaluated against a policy without a conversion that does not exist yet, and the two structs will drift. DESIGN §5.1 describes one override mechanism, not one per aggregate. Reuse a single type — rename `MovieOverrides` to `TitleOverrides` and drop this one. <!-- agent-meta: {"model":"claude-opus-5","session":"b9c31479"} -->
pub only_4k: bool,
pub allow_english_audio: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Series {
pub id: SeriesId,
pub tmdb_id: u64,
pub title: String,
pub year: u16,
pub original_language: Language,
pub root_id: RootId,
pub auto_track: bool,
pub overrides: SeriesOverrides,
pub blocked: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Season {
pub id: SeasonId,
pub series_id: SeriesId,
pub number: u16,
pub tracked: bool,
}
naps62-yolo marked this conversation as resolved
Review

MovieState and EpisodeState are now the same two-line enum twice over, which is the duplication TitleOverrides just removed one instance of. Worth the same treatment, or a comment saying the two are expected to diverge.

Related: pub type MovieOverrides = TitleOverrides keeps the old name alive for five in-tree call sites (policy.rs:58, policy.rs:106, search.rs:6, search.rs:296, search.rs:463). Nothing outside this workspace consumes it, so the alias can go with a rename in the same pass.

`MovieState` and `EpisodeState` are now the same two-line enum twice over, which is the duplication `TitleOverrides` just removed one instance of. Worth the same treatment, or a comment saying the two are expected to diverge. Related: `pub type MovieOverrides = TitleOverrides` keeps the old name alive for five in-tree call sites (`policy.rs:58`, `policy.rs:106`, `search.rs:6`, `search.rs:296`, `search.rs:463`). Nothing outside this workspace consumes it, so the alias can go with a rename in the same pass. <!-- agent-meta: {"model":"claude-opus-5","session":"b9c31479"} -->
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum EpisodeState {
naps62-yolo marked this conversation as resolved
Review

EpisodeState is Missing | Downloading | Available; the column added in this migration is CHECK (state IN ('missing', 'grabbed', 'imported')).

Movies already have this split, and 0001_movies.sql says arr-core "owns the canonical enum this mirrors" — it does not mirror it. This PR makes it two mismatches instead of one. Pick one vocabulary here, or leave a comment saying which side is authoritative.

`EpisodeState` is `Missing | Downloading | Available`; the column added in this migration is `CHECK (state IN ('missing', 'grabbed', 'imported'))`. Movies already have this split, and `0001_movies.sql` says arr-core "owns the canonical enum this mirrors" — it does not mirror it. This PR makes it two mismatches instead of one. Pick one vocabulary here, or leave a comment saying which side is authoritative. <!-- agent-meta: {"model":"claude-opus-5","session":"b9c31479"} -->
Missing,
Downloading,
Available,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Episode {
pub id: EpisodeId,
pub season_id: SeasonId,
pub number: u16,
pub title: String,
pub air_date: Option<SystemTime>,
pub wanted: bool,
pub state: EpisodeState,
pub search_attempts: u32,
pub last_searched_at: Option<SystemTime>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AudioTrack {
pub language: Language,