You've already forked flix
Model refinement
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct Model {
|
||||
/// The collection's directory
|
||||
pub directory: PathBytes,
|
||||
/// The collection's poster path
|
||||
pub relative_poster_path: Option<PathBytes>,
|
||||
pub relative_poster_path: Option<String>,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -51,6 +51,24 @@ pub enum Relation {
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Library,
|
||||
/// The media info for this collection
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::info::collections::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::info::collections::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MediaInfo,
|
||||
/// The watched info for this collection
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::watched::collections::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::watched::collections::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WatchInfo,
|
||||
}
|
||||
|
||||
impl Related<super::collections::Entity> for Entity {
|
||||
@@ -64,3 +82,15 @@ impl Related<super::libraries::Entity> for Entity {
|
||||
Relation::Library.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::info::collections::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MediaInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::watched::collections::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WatchInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ pub struct Model {
|
||||
/// The episode's number
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub episode: EpisodeNumber,
|
||||
/// The number of additional contained episodes
|
||||
pub count: u8,
|
||||
/// The episode's slug
|
||||
pub slug: String,
|
||||
/// The episode's library
|
||||
@@ -30,9 +32,9 @@ pub struct Model {
|
||||
/// The episode's directory
|
||||
pub directory: PathBytes,
|
||||
/// The episode's media path
|
||||
pub relative_media_path: PathBytes,
|
||||
pub relative_media_path: String,
|
||||
/// The episode's poster path
|
||||
pub relative_poster_path: Option<PathBytes>,
|
||||
pub relative_poster_path: Option<String>,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -49,6 +51,24 @@ pub enum Relation {
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Library,
|
||||
/// The media info for this episode
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::info::seasons::Entity",
|
||||
from = "(Column::Show, Column::Season)",
|
||||
to = "(super::super::info::seasons::Column::Show, super::super::info::seasons::Column::Season)",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MediaInfo,
|
||||
/// The watched info for this episode
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::watched::episodes::Entity",
|
||||
from = "(Column::Show, Column::Season, Column::Episode)",
|
||||
to = "(super::super::watched::episodes::Column::Show, super::super::watched::episodes::Column::Season, super::super::watched::episodes::Column::Episode)",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WatchInfo,
|
||||
}
|
||||
|
||||
impl Related<super::libraries::Entity> for Entity {
|
||||
@@ -56,3 +76,15 @@ impl Related<super::libraries::Entity> for Entity {
|
||||
Relation::Library.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::info::episodes::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MediaInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::watched::episodes::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WatchInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ mod tests {
|
||||
assert_eq!(model.slug, concat!("C/", $id).to_string());
|
||||
assert_eq!(model.library, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("/C/", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, Path::new(concat!("C/Poster", $id)).to_owned().into() $(, $($skip),+)?));
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, concat!("C/Poster", $id).to_owned() $(, $($skip),+)?));
|
||||
};
|
||||
($db:expr, $id:literal, $pid:expr, $lid:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
let model = assert_collection!(@insert, $db, $id, $pid, $lid $(; $($skip),+)?)
|
||||
@@ -89,7 +89,7 @@ mod tests {
|
||||
slug: notsettable!(slug, concat!("C/", $id).to_string() $(, $($skip),+)?),
|
||||
library: notsettable!(library, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("/C/", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(Path::new(concat!("C/Poster", $id)).to_owned().into()) $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(concat!("C/Poster", $id).to_owned()) $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
}
|
||||
@@ -129,8 +129,8 @@ mod tests {
|
||||
assert_eq!(model.slug, concat!("M/", $id).to_string());
|
||||
assert_eq!(model.library, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("/M/", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_media_path, Path::new(concat!("M/Media", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, Path::new(concat!("M/Poster", $id)).to_owned().into() $(, $($skip),+)?));
|
||||
assert_eq!(model.relative_media_path, concat!("M/Media", $id));
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, concat!("M/Poster", $id).to_owned() $(, $($skip),+)?));
|
||||
};
|
||||
($db:expr, $id:literal, $pid:expr, $lid:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
let model = assert_movie!(@insert, $db, $id, $pid, $lid $(; $($skip),+)?)
|
||||
@@ -145,8 +145,8 @@ mod tests {
|
||||
slug: notsettable!(slug, concat!("M/", $id).to_string() $(, $($skip),+)?),
|
||||
library: notsettable!(library, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("/M/", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_media_path: notsettable!(relative_media_path, Path::new(concat!("M/Media", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(Path::new(concat!("M/Poster", $id)).to_owned().into()) $(, $($skip),+)?),
|
||||
relative_media_path: notsettable!(relative_media_path, concat!("M/Media", $id).to_owned() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(concat!("M/Poster", $id).to_owned()) $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
}
|
||||
@@ -187,7 +187,7 @@ mod tests {
|
||||
assert_eq!(model.slug, concat!("S/", $id).to_string());
|
||||
assert_eq!(model.library, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("/S/", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, Path::new(concat!("S/Poster", $id)).to_owned().into() $(, $($skip),+)?));
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, concat!("S/Poster", $id).to_owned() $(, $($skip),+)?));
|
||||
};
|
||||
($db:expr, $id:literal, $pid:expr, $lid:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
let model = assert_show!(@insert, $db, $id, $pid, $lid $(; $($skip),+)?)
|
||||
@@ -202,7 +202,7 @@ mod tests {
|
||||
slug: notsettable!(slug, concat!("S/", $id).to_string() $(, $($skip),+)?),
|
||||
library: notsettable!(library, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("/S/", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(Path::new(concat!("S/Poster", $id)).to_owned().into()) $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(concat!("S/Poster", $id).to_owned()) $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
}
|
||||
@@ -242,7 +242,7 @@ mod tests {
|
||||
assert_eq!(model.slug, concat!("S/S", $id).to_string());
|
||||
assert_eq!(model.library, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("/S/S", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, Path::new(concat!("S/S/Poster", $id)).to_owned().into() $(, $($skip),+)?));
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, concat!("S/S/Poster", $id).to_owned() $(, $($skip),+)?));
|
||||
};
|
||||
($db:expr, $id:literal, $season:literal, $lid:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
let model = assert_season!(@insert, $db, $id, $season, $lid $(; $($skip),+)?)
|
||||
@@ -257,7 +257,7 @@ mod tests {
|
||||
slug: notsettable!(slug, concat!("S/S", $id).to_string() $(, $($skip),+)?),
|
||||
library: notsettable!(library, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("/S/S", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(Path::new(concat!("S/S/Poster", $id)).to_owned().into()) $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(concat!("S/S/Poster", $id).to_owned()) $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
}
|
||||
@@ -292,8 +292,8 @@ mod tests {
|
||||
assert_eq!(model.slug, concat!("S/S/E", $id).to_string());
|
||||
assert_eq!(model.library, LibraryId::from_raw($lid));
|
||||
assert_eq!(model.directory, Path::new(concat!("/S/S/E", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_media_path, Path::new(concat!("E/Media", $id)).to_owned().into());
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, Path::new(concat!("S/S/E/Poster", $id)).to_owned().into() $(, $($skip),+)?));
|
||||
assert_eq!(model.relative_media_path, concat!("E/Media", $id));
|
||||
assert_eq!(model.relative_poster_path, noneable!(relative_poster_path, concat!("S/S/E/Poster", $id).to_owned() $(, $($skip),+)?));
|
||||
};
|
||||
($db:expr, $id:literal, $season:literal, $episode:literal, $lid:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||
let model = assert_episode!(@insert, $db, $id, $season, $episode, $lid $(; $($skip),+)?)
|
||||
@@ -306,11 +306,12 @@ mod tests {
|
||||
show: notsettable!(id, ShowId::from_raw($id) $(, $($skip),+)?),
|
||||
season: notsettable!(season, $season $(, $($skip),+)?),
|
||||
episode: notsettable!(episode, $episode $(, $($skip),+)?),
|
||||
count: notsettable!(count, 0 $(, $($skip),+)?),
|
||||
slug: notsettable!(slug, concat!("S/S/E", $id).to_string() $(, $($skip),+)?),
|
||||
library: notsettable!(library, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||
directory: notsettable!(directory, Path::new(concat!("/S/S/E", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_media_path: notsettable!(relative_media_path, Path::new(concat!("E/Media", $id)).to_owned().into() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(Path::new(concat!("S/S/E/Poster", $id)).to_owned().into()) $(, $($skip),+)?),
|
||||
relative_media_path: notsettable!(relative_media_path, concat!("E/Media", $id).to_owned() $(, $($skip),+)?),
|
||||
relative_poster_path: notsettable!(relative_poster_path, Some(concat!("S/S/E/Poster", $id).to_owned()) $(, $($skip),+)?),
|
||||
}.insert($db).await
|
||||
};
|
||||
}
|
||||
@@ -320,9 +321,9 @@ mod tests {
|
||||
make_flix_episode!(&db, 1, 1, 2);
|
||||
make_flix_episode!(&db, 2, 1, 1);
|
||||
make_flix_episode!(&db, 3, 1, 1);
|
||||
make_flix_show!(&db, 10);
|
||||
make_flix_season!(&db, 10, 1);
|
||||
make_flix_episode!(&db, 10, 1, 1);
|
||||
make_flix_show!(&db, 11);
|
||||
make_flix_season!(&db, 11, 1);
|
||||
make_flix_episode!(&db, 11, 1, 1);
|
||||
|
||||
assert_episode!(&db, 1, 1, 1, 1, Success);
|
||||
assert_episode!(&db, 1, 1, 2, 1, Success);
|
||||
@@ -331,10 +332,11 @@ mod tests {
|
||||
assert_episode!(&db, 3, 1, 1, 1, Success; show);
|
||||
assert_episode!(&db, 4, 1, 1, 1, NotNullViolation; season);
|
||||
assert_episode!(&db, 5, 1, 1, 1, NotNullViolation; episode);
|
||||
assert_episode!(&db, 6, 1, 1, 1, NotNullViolation; slug);
|
||||
assert_episode!(&db, 7, 1, 1, 1, NotNullViolation; library);
|
||||
assert_episode!(&db, 8, 1, 1, 1, NotNullViolation; directory);
|
||||
assert_episode!(&db, 9, 1, 1, 1, NotNullViolation; relative_media_path);
|
||||
assert_episode!(&db, 10, 1, 1, 1, Success; relative_poster_path);
|
||||
assert_episode!(&db, 6, 1, 1, 1, NotNullViolation; count);
|
||||
assert_episode!(&db, 7, 1, 1, 1, NotNullViolation; slug);
|
||||
assert_episode!(&db, 8, 1, 1, 1, NotNullViolation; library);
|
||||
assert_episode!(&db, 9, 1, 1, 1, NotNullViolation; directory);
|
||||
assert_episode!(&db, 10, 1, 1, 1, NotNullViolation; relative_media_path);
|
||||
assert_episode!(&db, 11, 1, 1, 1, Success; relative_poster_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ pub struct Model {
|
||||
/// The movie's directory
|
||||
pub directory: PathBytes,
|
||||
/// The movie's media path
|
||||
pub relative_media_path: PathBytes,
|
||||
pub relative_media_path: String,
|
||||
/// The movie's poster path
|
||||
pub relative_poster_path: Option<PathBytes>,
|
||||
pub relative_poster_path: Option<String>,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -53,6 +53,24 @@ pub enum Relation {
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Library,
|
||||
/// The media info for this movie
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::info::movies::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::info::movies::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MediaInfo,
|
||||
/// The watched info for this movie
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::watched::movies::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::watched::movies::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WatchInfo,
|
||||
}
|
||||
|
||||
impl Related<super::collections::Entity> for Entity {
|
||||
@@ -66,3 +84,15 @@ impl Related<super::libraries::Entity> for Entity {
|
||||
Relation::Library.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::info::movies::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MediaInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::watched::movies::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WatchInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ pub struct Model {
|
||||
/// The season's directory
|
||||
pub directory: PathBytes,
|
||||
/// The season's poster path
|
||||
pub relative_poster_path: Option<PathBytes>,
|
||||
pub relative_poster_path: Option<String>,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -44,6 +44,24 @@ pub enum Relation {
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Library,
|
||||
/// The media info for this show
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::info::seasons::Entity",
|
||||
from = "(Column::Show, Column::Season)",
|
||||
to = "(super::super::info::seasons::Column::Show, super::super::info::seasons::Column::Season)",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MediaInfo,
|
||||
/// The watched info for this show
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::watched::seasons::Entity",
|
||||
from = "(Column::Show, Column::Season)",
|
||||
to = "(super::super::watched::seasons::Column::Show, super::super::watched::seasons::Column::Season)",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WatchInfo,
|
||||
}
|
||||
|
||||
impl Related<super::libraries::Entity> for Entity {
|
||||
@@ -51,3 +69,15 @@ impl Related<super::libraries::Entity> for Entity {
|
||||
Relation::Library.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::info::seasons::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MediaInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::watched::seasons::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WatchInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ pub struct Model {
|
||||
/// The show's directory
|
||||
pub directory: PathBytes,
|
||||
/// The show's poster path
|
||||
pub relative_poster_path: Option<PathBytes>,
|
||||
pub relative_poster_path: Option<String>,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -51,6 +51,24 @@ pub enum Relation {
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Library,
|
||||
/// The media info for this show
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::info::shows::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::info::shows::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
MediaInfo,
|
||||
/// The watched info for this show
|
||||
#[sea_orm(
|
||||
belongs_to = "super::super::watched::shows::Entity",
|
||||
from = "Column::Id",
|
||||
to = "super::super::watched::shows::Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
WatchInfo,
|
||||
}
|
||||
|
||||
impl Related<super::collections::Entity> for Entity {
|
||||
@@ -64,3 +82,15 @@ impl Related<super::libraries::Entity> for Entity {
|
||||
Relation::Library.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::info::shows::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::MediaInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::super::watched::shows::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WatchInfo.def()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user