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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ mod tests {
|
||||
slug: Set(::std::string::String::new()),
|
||||
library: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
relative_poster_path: Set(None),
|
||||
relative_poster_path: Set(::core::option::Option::None),
|
||||
}
|
||||
.insert($db)
|
||||
.await
|
||||
@@ -144,8 +144,8 @@ mod tests {
|
||||
slug: Set(::std::string::String::new()),
|
||||
library: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
relative_media_path: Set(::std::path::PathBuf::new().into()),
|
||||
relative_poster_path: Set(None),
|
||||
relative_media_path: Set(::std::string::String::new()),
|
||||
relative_poster_path: Set(::core::option::Option::None),
|
||||
}
|
||||
.insert($db)
|
||||
.await
|
||||
@@ -181,7 +181,7 @@ mod tests {
|
||||
slug: Set(::std::string::String::new()),
|
||||
library: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
relative_poster_path: Set(None),
|
||||
relative_poster_path: Set(::core::option::Option::None),
|
||||
}
|
||||
.insert($db)
|
||||
.await
|
||||
@@ -216,7 +216,7 @@ mod tests {
|
||||
slug: Set(::std::string::String::new()),
|
||||
library: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
relative_poster_path: Set(None),
|
||||
relative_poster_path: Set(::core::option::Option::None),
|
||||
}
|
||||
.insert($db)
|
||||
.await
|
||||
@@ -245,16 +245,23 @@ mod tests {
|
||||
pub(super) use make_flix_episode;
|
||||
macro_rules! have_episode {
|
||||
($db:expr, $lid:literal, $show:literal, $season:literal, $episode:literal) => {
|
||||
have_episode!(@make, $db, $lid, $show, $season, $episode, 0);
|
||||
};
|
||||
($db:expr, $lid:literal, $show:literal, $season:literal, $episode:literal, >1) => {
|
||||
have_episode!(@make, $db, $lid, $show, $season, $episode, 1);
|
||||
};
|
||||
(@make, $db:expr, $lid:literal, $show:literal, $season:literal, $episode:literal, $count:literal) => {
|
||||
$crate::entity::tests::make_flix_episode!($db, $show, $season, $episode);
|
||||
$crate::entity::content::episodes::ActiveModel {
|
||||
show: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||
season: Set($season),
|
||||
episode: Set($episode),
|
||||
count: Set($count),
|
||||
slug: Set(::std::string::String::new()),
|
||||
library: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||
directory: Set(::std::path::PathBuf::new().into()),
|
||||
relative_media_path: Set(::std::path::PathBuf::new().into()),
|
||||
relative_poster_path: Set(None),
|
||||
relative_media_path: Set(::std::string::String::new()),
|
||||
relative_poster_path: Set(::core::option::Option::None),
|
||||
}
|
||||
.insert($db)
|
||||
.await
|
||||
|
||||
@@ -181,12 +181,10 @@ mod tests {
|
||||
have_episode!(&db, 1, 1, 1, 1);
|
||||
assert_episode!(&db, 1, 1, 1, 1, Success);
|
||||
assert_episode!(&db, 1, 1, 1, 2, Success);
|
||||
have_episode!(&db, 1, 1, 1, 2);
|
||||
have_episode!(&db, 1, 1, 1, 2, >1); // Covers 2 and 3
|
||||
make_flix_episode!(&db, 1, 1, 3);
|
||||
assert_episode!(&db, 1, 1, 2, 1, Success);
|
||||
assert_episode!(&db, 1, 1, 2, 2, Success);
|
||||
have_episode!(&db, 1, 1, 1, 3);
|
||||
assert_episode!(&db, 1, 1, 3, 1, Success);
|
||||
assert_episode!(&db, 1, 1, 3, 2, Success);
|
||||
have_season!(&db, 1, 1, 2);
|
||||
have_episode!(&db, 1, 1, 2, 1);
|
||||
assert_episode!(&db, 1, 2, 1, 1, Success);
|
||||
|
||||
@@ -4,7 +4,7 @@ use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, integer_null, string};
|
||||
use sea_orm_migration::schema::{binary, integer, integer_null, string, string_null};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoCollections;
|
||||
use crate::migration::m_000003::FlixLibraries;
|
||||
@@ -30,7 +30,7 @@ pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
.col(string(FlixCollections::Slug))
|
||||
.col(integer(FlixCollections::Library))
|
||||
.col(binary(FlixCollections::Directory))
|
||||
.col(binary_null(FlixCollections::RelativePosterPath))
|
||||
.col(string_null(FlixCollections::RelativePosterPath))
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_collections-id")
|
||||
|
||||
@@ -2,7 +2,7 @@ use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Index, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, string};
|
||||
use sea_orm_migration::schema::{binary, integer, string, string_null};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoEpisodes;
|
||||
use crate::migration::m_000003::FlixLibraries;
|
||||
@@ -13,6 +13,7 @@ pub enum FlixEpisodes {
|
||||
Show,
|
||||
Season,
|
||||
Episode,
|
||||
Count,
|
||||
Slug,
|
||||
Library,
|
||||
Directory,
|
||||
@@ -28,11 +29,12 @@ pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
.col(integer(FlixEpisodes::Show))
|
||||
.col(integer(FlixEpisodes::Season))
|
||||
.col(integer(FlixEpisodes::Episode))
|
||||
.col(integer(FlixEpisodes::Count))
|
||||
.col(string(FlixEpisodes::Slug))
|
||||
.col(integer(FlixEpisodes::Library))
|
||||
.col(binary(FlixEpisodes::Directory))
|
||||
.col(binary(FlixEpisodes::RelativeMediaPath))
|
||||
.col(binary_null(FlixEpisodes::RelativePosterPath))
|
||||
.col(string(FlixEpisodes::RelativeMediaPath))
|
||||
.col(string_null(FlixEpisodes::RelativePosterPath))
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(FlixEpisodes::Show)
|
||||
|
||||
@@ -4,7 +4,7 @@ use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, integer_null, string};
|
||||
use sea_orm_migration::schema::{binary, integer, integer_null, string, string_null};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoMovies;
|
||||
use crate::migration::m_000003::{FlixCollections, FlixLibraries};
|
||||
@@ -31,8 +31,8 @@ pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
.col(string(FlixMovies::Slug))
|
||||
.col(integer(FlixMovies::Library))
|
||||
.col(binary(FlixMovies::Directory))
|
||||
.col(binary(FlixMovies::RelativeMediaPath))
|
||||
.col(binary_null(FlixMovies::RelativePosterPath))
|
||||
.col(string(FlixMovies::RelativeMediaPath))
|
||||
.col(string_null(FlixMovies::RelativePosterPath))
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_movies-id")
|
||||
|
||||
@@ -2,7 +2,7 @@ use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Index, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, string};
|
||||
use sea_orm_migration::schema::{binary, integer, string, string_null};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoSeasons;
|
||||
use crate::migration::m_000003::FlixLibraries;
|
||||
@@ -28,7 +28,7 @@ pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
.col(string(FlixSeasons::Slug))
|
||||
.col(integer(FlixSeasons::Library))
|
||||
.col(binary(FlixSeasons::Directory))
|
||||
.col(binary_null(FlixSeasons::RelativePosterPath))
|
||||
.col(string_null(FlixSeasons::RelativePosterPath))
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(FlixSeasons::Show)
|
||||
|
||||
@@ -4,7 +4,7 @@ use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, integer_null, string};
|
||||
use sea_orm_migration::schema::{binary, integer, integer_null, string, string_null};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoShows;
|
||||
use crate::migration::m_000003::{FlixCollections, FlixLibraries};
|
||||
@@ -30,7 +30,7 @@ pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
.col(string(FlixShows::Slug))
|
||||
.col(integer(FlixShows::Library))
|
||||
.col(binary(FlixShows::Directory))
|
||||
.col(binary_null(FlixShows::RelativePosterPath))
|
||||
.col(string_null(FlixShows::RelativePosterPath))
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_shows-id")
|
||||
|
||||
Reference in New Issue
Block a user