You've already forked flix
Migrate to Zed and add proper newtypes
This commit is contained in:
Vendored
-9
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"vadimcn.vscode-lldb",
|
|
||||||
"barbosshack.crates-io",
|
|
||||||
"usernamehw.errorlens",
|
|
||||||
"tamasfe.even-better-toml",
|
|
||||||
"rust-lang.rust-analyzer",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Vendored
-33
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
// VSCode
|
|
||||||
"editor.detectIndentation": false,
|
|
||||||
"editor.insertSpaces": false,
|
|
||||||
"editor.tabSize": 4,
|
|
||||||
"files.exclude": {
|
|
||||||
"**/target": true,
|
|
||||||
"**/Cargo.lock": true,
|
|
||||||
},
|
|
||||||
"files.insertFinalNewline": true,
|
|
||||||
"files.trimFinalNewlines": true,
|
|
||||||
"files.trimTrailingWhitespace": true,
|
|
||||||
"files.watcherExclude": {
|
|
||||||
"**/.git/**": true,
|
|
||||||
"**/target/**": true,
|
|
||||||
},
|
|
||||||
// Extensions
|
|
||||||
"crates.listPreReleases": true,
|
|
||||||
"evenBetterToml.formatter.alignComments": true,
|
|
||||||
"evenBetterToml.formatter.alignEntries": false,
|
|
||||||
"evenBetterToml.formatter.allowedBlankLines": 1,
|
|
||||||
"evenBetterToml.formatter.arrayAutoExpand": true,
|
|
||||||
"evenBetterToml.formatter.arrayTrailingComma": true,
|
|
||||||
"evenBetterToml.formatter.columnWidth": 80,
|
|
||||||
"evenBetterToml.formatter.reorderKeys": true,
|
|
||||||
"evenBetterToml.formatter.trailingNewline": true,
|
|
||||||
"rust-analyzer.imports.granularity.enforce": true,
|
|
||||||
"rust-analyzer.imports.granularity.group": "module",
|
|
||||||
"rust-analyzer.imports.group.enable": true,
|
|
||||||
"rust-analyzer.imports.merge.glob": false,
|
|
||||||
"rust-analyzer.imports.preferNoStd": true,
|
|
||||||
"rust-analyzer.showUnlinkedFileNotification": false,
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"project_name": null,
|
||||||
|
|
||||||
|
"auto_install_extensions": {
|
||||||
|
"tombi": true,
|
||||||
|
"cargo-appraiser": true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"languages": {
|
||||||
|
"TOML": {
|
||||||
|
"format_on_save": "on",
|
||||||
|
"formatter": { "language_server": { "name": "tombi" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"lsp": {
|
||||||
|
"rust-analyzer": {
|
||||||
|
"initialization_options": {
|
||||||
|
"imports": {
|
||||||
|
"granularity": { "enforce": true, "group": "module" },
|
||||||
|
"group": { "enable": true },
|
||||||
|
"merge": { "glob": false },
|
||||||
|
"preferNoStd": true,
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"extraEnv": {
|
||||||
|
"RUSTUP_TOOLCHAIN": "stable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Generated
+536
-196
File diff suppressed because it is too large
Load Diff
+41
-45
@@ -1,18 +1,41 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/*"]
|
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
authors = []
|
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license-file = "LICENSE.md"
|
|
||||||
rust-version = "1.85.0"
|
rust-version = "1.85.0"
|
||||||
|
license-file = "LICENSE.md"
|
||||||
|
|
||||||
[workspace.lints.rust]
|
[workspace.dependencies]
|
||||||
arithmetic_overflow = "forbid"
|
anyhow = { version = "^1", default-features = false }
|
||||||
missing_docs = "forbid"
|
async-stream = { version = "^0.3", default-features = false }
|
||||||
unsafe_code = "forbid"
|
chrono = { version = "^0.4", default-features = false }
|
||||||
unused_doc_comments = "forbid"
|
clap = { version = "^4", default-features = false }
|
||||||
|
flix = { path = "crates/flix", version = "=0.0.16", default-features = false }
|
||||||
|
flix-cli = { path = "crates/cli", version = "=0.0.16", default-features = false }
|
||||||
|
flix-db = { path = "crates/db", version = "=0.0.16", default-features = false }
|
||||||
|
flix-fs = { path = "crates/fs", version = "=0.0.16", default-features = false }
|
||||||
|
flix-model = { path = "crates/model", version = "=0.0.16", default-features = false }
|
||||||
|
flix-tmdb = { path = "crates/tmdb", version = "=0.0.16", default-features = false }
|
||||||
|
futures = { version = "^0.3", default-features = false }
|
||||||
|
governor = { version = "^0.10", default-features = false }
|
||||||
|
nonzero_ext = { version = "^0.3", default-features = false }
|
||||||
|
regex = { version = "^1", default-features = false }
|
||||||
|
reqwest = { version = "^0.13", default-features = false }
|
||||||
|
sea-orm = { version = "2.0.0-rc.27", default-features = false }
|
||||||
|
sea-orm-migration = { version = "2.0.0-rc.27", default-features = false }
|
||||||
|
seamantic = { version = "^0.0.11", default-features = false }
|
||||||
|
serde = { version = "^1", default-features = false }
|
||||||
|
serde_test = { version = "^1", default-features = false }
|
||||||
|
thiserror = { version = "^2", default-features = false }
|
||||||
|
tokio = { version = "^1", default-features = false }
|
||||||
|
tokio-stream = { version = "^0.1", default-features = false }
|
||||||
|
toml = { version = "^0.9", default-features = false }
|
||||||
|
tracing = { version = "^0.1", default-features = false }
|
||||||
|
tracing-subscriber = { version = "^0.3", default-features = false }
|
||||||
|
url = { version = "^2", default-features = false }
|
||||||
|
url-macro = { version = "^0.2", default-features = false }
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
arithmetic_side_effects = "forbid"
|
arithmetic_side_effects = "forbid"
|
||||||
@@ -24,45 +47,18 @@ indexing_slicing = "forbid"
|
|||||||
integer_division = "forbid"
|
integer_division = "forbid"
|
||||||
integer_division_remainder_used = "forbid"
|
integer_division_remainder_used = "forbid"
|
||||||
transmute_undefined_repr = "forbid"
|
transmute_undefined_repr = "forbid"
|
||||||
unchecked_duration_subtraction = "forbid"
|
unchecked_time_subtraction = "forbid"
|
||||||
unwrap_used = "forbid"
|
unwrap_used = "forbid"
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
arithmetic_overflow = "forbid"
|
||||||
|
missing_docs = "forbid"
|
||||||
|
unsafe_code = "forbid"
|
||||||
|
unused_doc_comments = "forbid"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
|
||||||
lto = "fat"
|
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
overflow-checks = true
|
|
||||||
strip = "debuginfo"
|
strip = "debuginfo"
|
||||||
|
overflow-checks = true
|
||||||
[workspace.dependencies]
|
lto = "fat"
|
||||||
flix = { path = "crates/flix", version = "=0.0.15", default-features = false }
|
codegen-units = 1
|
||||||
flix-cli = { path = "crates/cli", version = "=0.0.15", default-features = false }
|
|
||||||
flix-db = { path = "crates/db", version = "=0.0.15", default-features = false }
|
|
||||||
flix-fs = { path = "crates/fs", version = "=0.0.15", default-features = false }
|
|
||||||
flix-model = { path = "crates/model", version = "=0.0.15", default-features = false }
|
|
||||||
flix-tmdb = { path = "crates/tmdb", version = "=0.0.15", default-features = false }
|
|
||||||
|
|
||||||
seamantic = { version = "0.0.10", default-features = false }
|
|
||||||
|
|
||||||
sea-orm = { version = "2.0.0-rc.18", default-features = false }
|
|
||||||
sea-orm-migration = { version = "2.0.0-rc.18", default-features = false }
|
|
||||||
|
|
||||||
anyhow = { version = "^1", default-features = false }
|
|
||||||
async-stream = { version = "^0.3", default-features = false }
|
|
||||||
chrono = { version = "^0.4", default-features = false }
|
|
||||||
clap = { version = "^4", default-features = false, features = ["std"] }
|
|
||||||
futures = { version = "^0.3", default-features = false }
|
|
||||||
governor = { version = "^0.10", default-features = false }
|
|
||||||
nonzero_ext = { version = "^0.3", default-features = false }
|
|
||||||
regex = { version = "^1", default-features = false }
|
|
||||||
reqwest = { version = "^0.12", default-features = false }
|
|
||||||
serde = { version = "^1", default-features = false }
|
|
||||||
serde_test = { version = "^1", default-features = false }
|
|
||||||
thiserror = { version = "^2", default-features = false }
|
|
||||||
tokio = { version = "^1", default-features = false }
|
|
||||||
tokio-stream = { version = "^0.1", default-features = false }
|
|
||||||
toml = { version = "^0.9", default-features = false }
|
|
||||||
tracing = { version = "^0.1", default-features = false }
|
|
||||||
tracing-subscriber = { version = "^0.3", default-features = false }
|
|
||||||
url = { version = "^2", default-features = false }
|
|
||||||
url-macro = { version = "^0.2", default-features = false }
|
|
||||||
|
|||||||
+28
-31
@@ -1,15 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-cli"
|
name = "flix-cli"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = ["command-line-utilities"]
|
rust-version.workspace = true
|
||||||
description = "CLI for interacting with a flix database"
|
description = "CLI for interacting with a flix database"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = ["command-line-utilities"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -20,9 +17,26 @@ doc = false
|
|||||||
name = "flix"
|
name = "flix"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[lints.rust]
|
[dependencies]
|
||||||
arithmetic_overflow = "forbid"
|
anyhow = { workspace = true }
|
||||||
unsafe_code = "forbid"
|
chrono = { workspace = true, features = ["now"] }
|
||||||
|
clap = { workspace = true, features = [
|
||||||
|
"color",
|
||||||
|
"derive",
|
||||||
|
"error-context",
|
||||||
|
"help",
|
||||||
|
"std",
|
||||||
|
"suggestions",
|
||||||
|
"usage",
|
||||||
|
] }
|
||||||
|
flix = { workspace = true, features = ["tmdb"] }
|
||||||
|
futures = { workspace = true }
|
||||||
|
sea-orm = { workspace = true, features = ["debug-print", "runtime-tokio"] }
|
||||||
|
serde = { workspace = true, features = ["derive"] }
|
||||||
|
tokio = { workspace = true, features = ["fs", "macros", "rt"] }
|
||||||
|
toml = { workspace = true, features = ["parse", "serde"] }
|
||||||
|
tracing = { workspace = true }
|
||||||
|
tracing-subscriber = { workspace = true }
|
||||||
|
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
arithmetic_side_effects = "deny"
|
arithmetic_side_effects = "deny"
|
||||||
@@ -34,26 +48,9 @@ indexing_slicing = "deny"
|
|||||||
integer_division = "deny"
|
integer_division = "deny"
|
||||||
integer_division_remainder_used = "deny"
|
integer_division_remainder_used = "deny"
|
||||||
transmute_undefined_repr = "deny"
|
transmute_undefined_repr = "deny"
|
||||||
unchecked_duration_subtraction = "deny"
|
unchecked_time_subtraction = "deny"
|
||||||
unwrap_used = "deny"
|
unwrap_used = "deny"
|
||||||
|
|
||||||
[dependencies]
|
[lints.rust]
|
||||||
flix = { workspace = true, features = ["tmdb"] }
|
arithmetic_overflow = "forbid"
|
||||||
|
unsafe_code = "forbid"
|
||||||
anyhow = { workspace = true }
|
|
||||||
chrono = { workspace = true, features = ["now"] }
|
|
||||||
clap = { workspace = true, features = [
|
|
||||||
"derive",
|
|
||||||
"color",
|
|
||||||
"error-context",
|
|
||||||
"help",
|
|
||||||
"suggestions",
|
|
||||||
"usage",
|
|
||||||
] }
|
|
||||||
futures = { workspace = true }
|
|
||||||
sea-orm = { workspace = true, features = ["runtime-tokio", "debug-print"] }
|
|
||||||
serde = { workspace = true, features = ["derive"] }
|
|
||||||
tokio = { workspace = true, features = ["rt", "fs", "macros"] }
|
|
||||||
toml = { workspace = true, features = ["parse", "serde"] }
|
|
||||||
tracing = { workspace = true }
|
|
||||||
tracing-subscriber = { workspace = true }
|
|
||||||
|
|||||||
@@ -150,13 +150,20 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
|||||||
let year = show.first_air_date.year();
|
let year = show.first_air_date.year();
|
||||||
|
|
||||||
for season in 1..=show.number_of_seasons {
|
for season in 1..=show.number_of_seasons {
|
||||||
let season = client
|
let season = SeasonNumber::new(season);
|
||||||
|
let season = match client
|
||||||
.seasons()
|
.seasons()
|
||||||
.get_details(id, season, None)
|
.get_details(id, season, None)
|
||||||
.await
|
.await
|
||||||
.with_context(|| {
|
.with_context(|| {
|
||||||
format!("seasons().get_details({}, {})", id.into_raw(), season)
|
format!("seasons().get_details({}, {})", id.into_raw(), season)
|
||||||
})?;
|
}) {
|
||||||
|
Ok(season) => season,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("{err:?}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
if season.air_date > Utc::now().naive_utc().date() {
|
if season.air_date > Utc::now().naive_utc().date() {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"skipping season ({}, {})",
|
"skipping season ({}, {})",
|
||||||
@@ -166,7 +173,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ok(number_of_episodes) = EpisodeNumber::try_from(season.episodes.len()) else {
|
let Ok(number_of_episodes) = u32::try_from(season.episodes.len()) else {
|
||||||
bail!(
|
bail!(
|
||||||
"could not convert {} to an EpisodeNumber",
|
"could not convert {} to an EpisodeNumber",
|
||||||
season.episodes.len()
|
season.episodes.len()
|
||||||
@@ -175,6 +182,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
|||||||
|
|
||||||
let mut season_episodes = Vec::new();
|
let mut season_episodes = Vec::new();
|
||||||
for episode in 1..=number_of_episodes {
|
for episode in 1..=number_of_episodes {
|
||||||
|
let episode = EpisodeNumber::new(episode);
|
||||||
let Ok(episode) = client
|
let Ok(episode) = client
|
||||||
.episodes()
|
.episodes()
|
||||||
.get_details(id, season.season_number, episode, None)
|
.get_details(id, season.season_number, episode, None)
|
||||||
@@ -314,7 +322,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
|||||||
})?;
|
})?;
|
||||||
let mut episodes = Vec::new();
|
let mut episodes = Vec::new();
|
||||||
|
|
||||||
let Ok(number_of_episodes) = EpisodeNumber::try_from(season.episodes.len()) else {
|
let Ok(number_of_episodes) = u32::try_from(season.episodes.len()) else {
|
||||||
bail!(
|
bail!(
|
||||||
"could not convert {} to an EpisodeNumber",
|
"could not convert {} to an EpisodeNumber",
|
||||||
season.episodes.len()
|
season.episodes.len()
|
||||||
@@ -322,6 +330,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
|
|||||||
};
|
};
|
||||||
|
|
||||||
for episode in 1..=number_of_episodes {
|
for episode in 1..=number_of_episodes {
|
||||||
|
let episode = EpisodeNumber::new(episode);
|
||||||
let Ok(episode) = client
|
let Ok(episode) = client
|
||||||
.episodes()
|
.episodes()
|
||||||
.get_details(id, season.season_number, episode, None)
|
.get_details(id, season.season_number, episode, None)
|
||||||
|
|||||||
+15
-21
@@ -1,45 +1,39 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-db"
|
name = "flix-db"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = []
|
rust-version.workspace = true
|
||||||
description = "Types for storing persistent data about media"
|
description = "Types for storing persistent data about media"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
tmdb = ["dep:flix-tmdb"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flix-model = { workspace = true }
|
|
||||||
|
|
||||||
flix-tmdb = { workspace = true, optional = true, features = ["sea-orm"] }
|
|
||||||
|
|
||||||
seamantic = { workspace = true, features = ["sqlite"] }
|
|
||||||
|
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
|
flix-model = { workspace = true }
|
||||||
|
flix-tmdb = { workspace = true, features = ["sea-orm"], optional = true }
|
||||||
sea-orm = { workspace = true, features = [
|
sea-orm = { workspace = true, features = [
|
||||||
"entity-registry",
|
"entity-registry",
|
||||||
"schema-sync",
|
"schema-sync",
|
||||||
"with-chrono",
|
"with-chrono",
|
||||||
] }
|
] }
|
||||||
sea-orm-migration = { workspace = true }
|
sea-orm-migration = { workspace = true }
|
||||||
|
seamantic = { workspace = true, features = ["sqlite"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sea-orm-migration = { workspace = true, features = ["runtime-tokio-rustls"] }
|
sea-orm-migration = { workspace = true, features = ["runtime-tokio-rustls"] }
|
||||||
tokio = { version = "^1", default-features = false, features = [
|
tokio = { version = "^1", default-features = false, features = [
|
||||||
"rt",
|
|
||||||
"macros",
|
"macros",
|
||||||
|
"rt",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
tmdb = ["dep:flix-tmdb"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ pub mod test {
|
|||||||
$crate::entity::info::test::make_info_season!($db, $show, $season);
|
$crate::entity::info::test::make_info_season!($db, $show, $season);
|
||||||
$crate::entity::content::seasons::ActiveModel {
|
$crate::entity::content::seasons::ActiveModel {
|
||||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||||
season_number: Set($season),
|
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
slug: Set(concat!("SS ", $show, $season).to_string()),
|
slug: Set(concat!("SS ", $show, $season).to_string()),
|
||||||
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||||
directory: Set(::std::path::PathBuf::new().into()),
|
directory: Set(::std::path::PathBuf::new().into()),
|
||||||
@@ -408,8 +408,8 @@ pub mod test {
|
|||||||
$crate::entity::info::test::make_info_episode!($db, $show, $season, $episode);
|
$crate::entity::info::test::make_info_episode!($db, $show, $season, $episode);
|
||||||
$crate::entity::content::episodes::ActiveModel {
|
$crate::entity::content::episodes::ActiveModel {
|
||||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||||
season_number: Set($season),
|
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
episode_number: Set($episode),
|
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||||
count: Set($count),
|
count: Set($count),
|
||||||
slug: Set(concat!("SSE ", $show, $season, $episode).to_string()),
|
slug: Set(concat!("SSE ", $show, $season, $episode).to_string()),
|
||||||
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
library_id: Set(::flix_model::id::LibraryId::from_raw($lid)),
|
||||||
@@ -690,7 +690,7 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.show_id, ShowId::from_raw($id));
|
assert_eq!(model.show_id, ShowId::from_raw($id));
|
||||||
assert_eq!(model.season_number, $season);
|
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season).to_string());
|
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season).to_string());
|
||||||
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
||||||
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into());
|
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into());
|
||||||
@@ -705,7 +705,7 @@ mod tests {
|
|||||||
(@insert, $db:expr, $id:literal, $season:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $id:literal, $season:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
||||||
super::seasons::ActiveModel {
|
super::seasons::ActiveModel {
|
||||||
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
||||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season).to_string() $(, $($skip),+)?),
|
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season).to_string() $(, $($skip),+)?),
|
||||||
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||||
directory: notsettable!(directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into() $(, $($skip),+)?),
|
directory: notsettable!(directory, Path::new(concat!("SS Directory ", $id, ",", $season)).to_owned().into() $(, $($skip),+)?),
|
||||||
@@ -745,8 +745,8 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.show_id, ShowId::from_raw($id));
|
assert_eq!(model.show_id, ShowId::from_raw($id));
|
||||||
assert_eq!(model.season_number, $season);
|
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.episode_number, $episode);
|
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||||
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string());
|
assert_eq!(model.slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string());
|
||||||
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
assert_eq!(model.library_id, LibraryId::from_raw($lid));
|
||||||
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season, $episode)).to_owned().into());
|
assert_eq!(model.directory, Path::new(concat!("SS Directory ", $id, ",", $season, $episode)).to_owned().into());
|
||||||
@@ -762,8 +762,8 @@ mod tests {
|
|||||||
(@insert, $db:expr, $id:literal, $season:literal, $episode:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $id:literal, $season:literal, $episode:literal, $lid:literal $(; $($skip:ident),+)?) => {
|
||||||
super::episodes::ActiveModel {
|
super::episodes::ActiveModel {
|
||||||
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
show_id: notsettable!(show_id, ShowId::from_raw($id) $(, $($skip),+)?),
|
||||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||||
count: notsettable!(count, 0 $(, $($skip),+)?),
|
count: notsettable!(count, 0 $(, $($skip),+)?),
|
||||||
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string() $(, $($skip),+)?),
|
slug: notsettable!(slug, concat!("SS Slug ", $id, ",", $season, $episode).to_string() $(, $($skip),+)?),
|
||||||
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
library_id: notsettable!(library_id, LibraryId::from_raw($lid) $(, $($skip),+)?),
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ pub mod test {
|
|||||||
($db:expr, $show:literal, $season:literal) => {
|
($db:expr, $show:literal, $season:literal) => {
|
||||||
$crate::entity::info::seasons::ActiveModel {
|
$crate::entity::info::seasons::ActiveModel {
|
||||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||||
season_number: Set($season),
|
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
title: Set(::std::string::String::new()),
|
title: Set(::std::string::String::new()),
|
||||||
overview: Set(::std::string::String::new()),
|
overview: Set(::std::string::String::new()),
|
||||||
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
||||||
@@ -244,8 +244,8 @@ pub mod test {
|
|||||||
($db:expr, $show:literal, $season:literal, $episode:literal) => {
|
($db:expr, $show:literal, $season:literal, $episode:literal) => {
|
||||||
$crate::entity::info::episodes::ActiveModel {
|
$crate::entity::info::episodes::ActiveModel {
|
||||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||||
season_number: Set($season),
|
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
episode_number: Set($episode),
|
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||||
title: Set(::std::string::String::new()),
|
title: Set(::std::string::String::new()),
|
||||||
overview: Set(::std::string::String::new()),
|
overview: Set(::std::string::String::new()),
|
||||||
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
date: Set(::chrono::NaiveDate::from_yo_opt(1, 1).expect("from_yo_opt")),
|
||||||
@@ -422,7 +422,7 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||||
assert_eq!(model.season_number, $season);
|
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.title, concat!("SS Title ", $show, ",", $season));
|
assert_eq!(model.title, concat!("SS Title ", $show, ",", $season));
|
||||||
assert_eq!(model.overview, concat!("SS Overview ", $show, ",", $season));
|
assert_eq!(model.overview, concat!("SS Overview ", $show, ",", $season));
|
||||||
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
||||||
@@ -439,7 +439,7 @@ mod tests {
|
|||||||
(@insert, $db:expr, $show:literal, $season:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $show:literal, $season:literal $(; $($skip:ident),+)?) => {
|
||||||
super::seasons::ActiveModel {
|
super::seasons::ActiveModel {
|
||||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
title: notsettable!(title, concat!("SS Title ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
title: notsettable!(title, concat!("SS Title ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
||||||
overview: notsettable!(overview, concat!("SS Overview ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
overview: notsettable!(overview, concat!("SS Overview ", $show, ",", $season).to_string() $(, $($skip),+)?),
|
||||||
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
||||||
@@ -473,8 +473,8 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||||
assert_eq!(model.season_number, $season);
|
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.episode_number, $episode);
|
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||||
assert_eq!(model.title, concat!("SSE Title ", $show, ",", $season, ",", $episode));
|
assert_eq!(model.title, concat!("SSE Title ", $show, ",", $season, ",", $episode));
|
||||||
assert_eq!(model.overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode));
|
assert_eq!(model.overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode));
|
||||||
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
assert_eq!(model.date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt"));
|
||||||
@@ -491,8 +491,8 @@ mod tests {
|
|||||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal $(; $($skip:ident),+)?) => {
|
||||||
super::episodes::ActiveModel {
|
super::episodes::ActiveModel {
|
||||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||||
title: notsettable!(title, concat!("SSE Title ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
title: notsettable!(title, concat!("SSE Title ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
||||||
overview: notsettable!(overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
overview: notsettable!(overview, concat!("SSE Overview ", $show, ",", $season, ",", $episode).to_string() $(, $($skip),+)?),
|
||||||
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
date: notsettable!(date, NaiveDate::from_yo_opt($show + $season, 1).expect("from_yo_opt") $(, $($skip),+)?),
|
||||||
|
|||||||
@@ -280,9 +280,9 @@ pub mod test {
|
|||||||
($db:expr, $show:literal, $season:literal, $flix_show:literal, $flix_season:literal) => {
|
($db:expr, $show:literal, $season:literal, $flix_show:literal, $flix_season:literal) => {
|
||||||
$crate::entity::tmdb::seasons::ActiveModel {
|
$crate::entity::tmdb::seasons::ActiveModel {
|
||||||
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
||||||
tmdb_season: Set($season),
|
tmdb_season: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
||||||
flix_season: Set($flix_season),
|
flix_season: Set(::flix_model::numbers::SeasonNumber::new($flix_season)),
|
||||||
last_update: Set(::chrono::Utc::now()),
|
last_update: Set(::chrono::Utc::now()),
|
||||||
}
|
}
|
||||||
.insert($db)
|
.insert($db)
|
||||||
@@ -296,11 +296,11 @@ pub mod test {
|
|||||||
($db:expr, $show:literal, $season:literal, $episode:literal, $flix_show:literal, $flix_season:literal, $flix_episode:literal) => {
|
($db:expr, $show:literal, $season:literal, $episode:literal, $flix_show:literal, $flix_season:literal, $flix_episode:literal) => {
|
||||||
$crate::entity::tmdb::episodes::ActiveModel {
|
$crate::entity::tmdb::episodes::ActiveModel {
|
||||||
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
tmdb_show: Set(::flix_tmdb::model::id::ShowId::from_raw($show)),
|
||||||
tmdb_season: Set($season),
|
tmdb_season: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
tmdb_episode: Set($episode),
|
tmdb_episode: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||||
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
flix_show: Set(::flix_model::id::ShowId::from_raw($flix_show)),
|
||||||
flix_season: Set($flix_season),
|
flix_season: Set(::flix_model::numbers::SeasonNumber::new($flix_season)),
|
||||||
flix_episode: Set($flix_episode),
|
flix_episode: Set(::flix_model::numbers::EpisodeNumber::new($flix_episode)),
|
||||||
last_update: Set(::chrono::Utc::now()),
|
last_update: Set(::chrono::Utc::now()),
|
||||||
runtime: Set(::core::default::Default::default()),
|
runtime: Set(::core::default::Default::default()),
|
||||||
}
|
}
|
||||||
@@ -514,9 +514,9 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
||||||
assert_eq!(model.tmdb_season, $tseason);
|
assert_eq!(model.tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason));
|
||||||
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
||||||
assert_eq!(model.flix_season, $season);
|
assert_eq!(model.flix_season, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||||
};
|
};
|
||||||
($db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal, $error:ident $(; $($skip:ident),+)?) => {
|
($db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal, $error:ident $(; $($skip:ident),+)?) => {
|
||||||
@@ -531,9 +531,9 @@ mod tests {
|
|||||||
(@insert, $db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $show:literal, $season:literal, $tshow:literal, $tseason:literal $(; $($skip:ident),+)?) => {
|
||||||
super::seasons::ActiveModel {
|
super::seasons::ActiveModel {
|
||||||
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
||||||
tmdb_season: notsettable!(tmdb_season, $tseason $(, $($skip),+)?),
|
tmdb_season: notsettable!(tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason) $(, $($skip),+)?),
|
||||||
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||||
flix_season: notsettable!(flix_season, $season $(, $($skip),+)?),
|
flix_season: notsettable!(flix_season, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||||
}.insert($db).await
|
}.insert($db).await
|
||||||
};
|
};
|
||||||
@@ -569,11 +569,11 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
assert_eq!(model.tmdb_show, TmdbShowId::from_raw($tshow));
|
||||||
assert_eq!(model.tmdb_season, $tseason);
|
assert_eq!(model.tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason));
|
||||||
assert_eq!(model.tmdb_episode, $tepisode);
|
assert_eq!(model.tmdb_episode, ::flix_model::numbers::EpisodeNumber::new($tepisode));
|
||||||
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
assert_eq!(model.flix_show, ShowId::from_raw($show));
|
||||||
assert_eq!(model.flix_season, $season);
|
assert_eq!(model.flix_season, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.flix_episode, $episode);
|
assert_eq!(model.flix_episode, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||||
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
assert_eq!(model.last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||||
assert_eq!(model.runtime, Duration::from_secs($tshow).into());
|
assert_eq!(model.runtime, Duration::from_secs($tshow).into());
|
||||||
};
|
};
|
||||||
@@ -589,11 +589,11 @@ mod tests {
|
|||||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $tshow:literal, $tseason:literal, $tepisode:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $tshow:literal, $tseason:literal, $tepisode:literal $(; $($skip:ident),+)?) => {
|
||||||
super::episodes::ActiveModel {
|
super::episodes::ActiveModel {
|
||||||
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
tmdb_show: notsettable!(tmdb_show, TmdbShowId::from_raw($tshow) $(, $($skip),+)?),
|
||||||
tmdb_season: notsettable!(tmdb_season, $tseason $(, $($skip),+)?),
|
tmdb_season: notsettable!(tmdb_season, ::flix_model::numbers::SeasonNumber::new($tseason) $(, $($skip),+)?),
|
||||||
tmdb_episode: notsettable!(tmdb_episode, $tepisode $(, $($skip),+)?),
|
tmdb_episode: notsettable!(tmdb_episode, ::flix_model::numbers::EpisodeNumber::new($tepisode) $(, $($skip),+)?),
|
||||||
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
flix_show: notsettable!(flix_show, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||||
flix_season: notsettable!(flix_season, $season $(, $($skip),+)?),
|
flix_season: notsettable!(flix_season, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
flix_episode: notsettable!(flix_episode, $episode $(, $($skip),+)?),
|
flix_episode: notsettable!(flix_episode, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||||
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
last_update: notsettable!(last_update, NaiveDate::from_yo_opt($tshow, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||||
runtime: notsettable!(runtime, Duration::from_secs($tshow).into() $(, $($skip),+)?),
|
runtime: notsettable!(runtime, Duration::from_secs($tshow).into() $(, $($skip),+)?),
|
||||||
}.insert($db).await
|
}.insert($db).await
|
||||||
|
|||||||
@@ -224,8 +224,8 @@ pub mod test {
|
|||||||
($db:expr, $show:literal, $season:literal, $episode:literal, $user:literal) => {
|
($db:expr, $show:literal, $season:literal, $episode:literal, $user:literal) => {
|
||||||
$crate::entity::watched::episodes::ActiveModel {
|
$crate::entity::watched::episodes::ActiveModel {
|
||||||
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
show_id: Set(::flix_model::id::ShowId::from_raw($show)),
|
||||||
season_number: Set($season),
|
season_number: Set(::flix_model::numbers::SeasonNumber::new($season)),
|
||||||
episode_number: Set($episode),
|
episode_number: Set(::flix_model::numbers::EpisodeNumber::new($episode)),
|
||||||
user_id: Set($user),
|
user_id: Set($user),
|
||||||
watched_date: Set(::chrono::Utc::now()),
|
watched_date: Set(::chrono::Utc::now()),
|
||||||
}
|
}
|
||||||
@@ -326,8 +326,8 @@ mod tests {
|
|||||||
.expect("insert");
|
.expect("insert");
|
||||||
|
|
||||||
assert_eq!(model.show_id, ShowId::from_raw($show));
|
assert_eq!(model.show_id, ShowId::from_raw($show));
|
||||||
assert_eq!(model.season_number, $season);
|
assert_eq!(model.season_number, ::flix_model::numbers::SeasonNumber::new($season));
|
||||||
assert_eq!(model.episode_number, $episode);
|
assert_eq!(model.episode_number, ::flix_model::numbers::EpisodeNumber::new($episode));
|
||||||
assert_eq!(model.user_id, $uid);
|
assert_eq!(model.user_id, $uid);
|
||||||
assert_eq!(model.watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
assert_eq!(model.watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc());
|
||||||
};
|
};
|
||||||
@@ -340,8 +340,8 @@ mod tests {
|
|||||||
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $uid:literal $(; $($skip:ident),+)?) => {
|
(@insert, $db:expr, $show:literal, $season:literal, $episode:literal, $uid:literal $(; $($skip:ident),+)?) => {
|
||||||
super::episodes::ActiveModel {
|
super::episodes::ActiveModel {
|
||||||
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
show_id: notsettable!(show_id, ShowId::from_raw($show) $(, $($skip),+)?),
|
||||||
season_number: notsettable!(season_number, $season $(, $($skip),+)?),
|
season_number: notsettable!(season_number, ::flix_model::numbers::SeasonNumber::new($season) $(, $($skip),+)?),
|
||||||
episode_number: notsettable!(episode_number, $episode $(, $($skip),+)?),
|
episode_number: notsettable!(episode_number, ::flix_model::numbers::EpisodeNumber::new($episode) $(, $($skip),+)?),
|
||||||
user_id: notsettable!(user_id, $uid $(, $($skip),+)?),
|
user_id: notsettable!(user_id, $uid $(, $($skip),+)?),
|
||||||
watched_date: notsettable!(watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
watched_date: notsettable!(watched_date, NaiveDate::from_yo_opt($uid, 1).expect("from_yo_opt").and_hms_opt(0, 0, 0).expect("and_hms_opt").and_utc() $(, $($skip),+)?),
|
||||||
}.insert($db).await
|
}.insert($db).await
|
||||||
|
|||||||
+11
-15
@@ -1,22 +1,22 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix"
|
name = "flix"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = []
|
rust-version.workspace = true
|
||||||
description = "Mechanisms for interacting with flix media"
|
description = "Mechanisms for interacting with flix media"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[lints]
|
[dependencies]
|
||||||
workspace = true
|
flix-db = { workspace = true }
|
||||||
|
flix-fs = { workspace = true, optional = true }
|
||||||
|
flix-model = { workspace = true }
|
||||||
|
flix-tmdb = { workspace = true, optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
@@ -24,9 +24,5 @@ fs = ["dep:flix-fs"]
|
|||||||
serde = ["flix-model/serde"]
|
serde = ["flix-model/serde"]
|
||||||
tmdb = ["dep:flix-tmdb", "flix-db/tmdb"]
|
tmdb = ["dep:flix-tmdb", "flix-db/tmdb"]
|
||||||
|
|
||||||
[dependencies]
|
[lints]
|
||||||
flix-db = { workspace = true }
|
workspace = true
|
||||||
flix-model = { workspace = true }
|
|
||||||
|
|
||||||
flix-fs = { workspace = true, optional = true }
|
|
||||||
flix-tmdb = { workspace = true, optional = true }
|
|
||||||
|
|||||||
+9
-13
@@ -1,28 +1,24 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-fs"
|
name = "flix-fs"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = []
|
rust-version.workspace = true
|
||||||
description = "Filesystem scanner for flix media"
|
description = "Filesystem scanner for flix media"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flix-model = { workspace = true }
|
|
||||||
|
|
||||||
async-stream = { workspace = true }
|
async-stream = { workspace = true }
|
||||||
regex = { workspace = true, features = ["std", "perf"] }
|
flix-model = { workspace = true }
|
||||||
|
regex = { workspace = true, features = ["perf", "std"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tokio-stream = { workspace = true, features = ["fs"] }
|
tokio-stream = { workspace = true, features = ["fs"] }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|||||||
+10
-14
@@ -1,29 +1,25 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-model"
|
name = "flix-model"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = []
|
rust-version.workspace = true
|
||||||
description = "Core types for flix data"
|
description = "Core types for flix data"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[lints]
|
[dependencies]
|
||||||
workspace = true
|
seamantic = { workspace = true }
|
||||||
|
serde = { workspace = true, features = ["derive", "std"], optional = true }
|
||||||
|
thiserror = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
serde = ["dep:serde"]
|
serde = ["dep:serde"]
|
||||||
|
|
||||||
[dependencies]
|
[lints]
|
||||||
seamantic = { workspace = true }
|
workspace = true
|
||||||
|
|
||||||
serde = { workspace = true, optional = true, features = ["std", "derive"] }
|
|
||||||
thiserror = { workspace = true }
|
|
||||||
|
|||||||
@@ -1,12 +1,76 @@
|
|||||||
//! This module contains season and episode numbers and related errors
|
//! This module contains season and episode numbers and related errors
|
||||||
|
|
||||||
|
use core::fmt;
|
||||||
use core::ops::RangeInclusive;
|
use core::ops::RangeInclusive;
|
||||||
|
use core::str::FromStr;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
/// Type alias for representing season numbers
|
use seamantic::sea_orm;
|
||||||
pub type SeasonNumber = u32;
|
|
||||||
/// Type alias for representing episode numbers
|
/// Newtype for representing season numbers
|
||||||
pub type EpisodeNumber = u32;
|
#[derive(
|
||||||
|
Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, sea_orm::DeriveValueType,
|
||||||
|
)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct SeasonNumber(u32);
|
||||||
|
|
||||||
|
impl SeasonNumber {
|
||||||
|
/// Create a `SeasonNumber` from an integer
|
||||||
|
pub fn new(value: u32) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for SeasonNumber {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
self.0.fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for SeasonNumber {
|
||||||
|
type Err = <u32 as FromStr>::Err;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
u32::from_str(s).map(Self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Newtype for representing episode numbers
|
||||||
|
#[derive(
|
||||||
|
Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, sea_orm::DeriveValueType,
|
||||||
|
)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
|
#[repr(transparent)]
|
||||||
|
pub struct EpisodeNumber(u32);
|
||||||
|
|
||||||
|
impl EpisodeNumber {
|
||||||
|
/// Create an `EpisodeNumber` from an integer
|
||||||
|
pub fn new(value: u32) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the underlying value
|
||||||
|
pub fn into_inner(self) -> u32 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for EpisodeNumber {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
self.0.fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for EpisodeNumber {
|
||||||
|
type Err = <u32 as FromStr>::Err;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
u32::from_str(s).map(Self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Potential errors when building EpisodeNumbers
|
/// Potential errors when building EpisodeNumbers
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
@@ -37,7 +101,7 @@ impl TryFrom<&[EpisodeNumber]> for EpisodeNumbers {
|
|||||||
let max = value.iter().copied().max().unwrap_or_default();
|
let max = value.iter().copied().max().unwrap_or_default();
|
||||||
let len = value.len();
|
let len = value.len();
|
||||||
|
|
||||||
if usize::try_from(max.saturating_sub(min).saturating_add(1)) != Ok(len) {
|
if usize::try_from(max.0.saturating_sub(min.0).saturating_add(1)) != Ok(len) {
|
||||||
return Err(Error::Noncontiguous);
|
return Err(Error::Noncontiguous);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +120,7 @@ impl EpisodeNumbers {
|
|||||||
/// Create an [EpisodeNumbers] from a starting number and a count.
|
/// Create an [EpisodeNumbers] from a starting number and a count.
|
||||||
/// `count` should be zero for single episodes.
|
/// `count` should be zero for single episodes.
|
||||||
pub fn new(start: EpisodeNumber, count: u8) -> Self {
|
pub fn new(start: EpisodeNumber, count: u8) -> Self {
|
||||||
Self(start..=start.saturating_add(count.into()))
|
Self(start..=EpisodeNumber(start.0.saturating_add(count.into())))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the range of episodes
|
/// Get the range of episodes
|
||||||
|
|||||||
+15
-20
@@ -1,40 +1,35 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flix-tmdb"
|
name = "flix-tmdb"
|
||||||
version = "0.0.15"
|
version = "0.0.16"
|
||||||
|
edition.workspace = true
|
||||||
categories = []
|
rust-version.workspace = true
|
||||||
description = "Clients and models for fetching data from TMDB"
|
description = "Clients and models for fetching data from TMDB"
|
||||||
repository = "https://github.com/QuantumShade/flix"
|
repository = "https://github.com/QuantumShade/flix"
|
||||||
|
|
||||||
authors.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
license-file.workspace = true
|
license-file.workspace = true
|
||||||
rust-version.workspace = true
|
categories = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
sea-orm = ["dep:sea-orm"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flix-model = { workspace = true }
|
|
||||||
|
|
||||||
chrono = { workspace = true, features = ["serde"] }
|
chrono = { workspace = true, features = ["serde"] }
|
||||||
governor = { workspace = true, features = ["std", "jitter"] }
|
flix-model = { workspace = true, features = ["serde"] }
|
||||||
|
governor = { workspace = true, features = ["jitter", "std"] }
|
||||||
nonzero_ext = { workspace = true }
|
nonzero_ext = { workspace = true }
|
||||||
reqwest = { workspace = true, features = ["json", "rustls-tls"] }
|
reqwest = { workspace = true, features = ["json", "query", "rustls"] }
|
||||||
|
sea-orm = { workspace = true, optional = true }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
url-macro = { workspace = true }
|
url-macro = { workspace = true }
|
||||||
|
|
||||||
sea-orm = { workspace = true, optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_test = { workspace = true }
|
serde_test = { workspace = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
sea-orm = ["dep:sea-orm"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
toml-version = "v1.0.0"
|
||||||
|
|
||||||
|
[format.rules]
|
||||||
|
indent-style = "tab"
|
||||||
|
indent-width = 4
|
||||||
Reference in New Issue
Block a user