Migrate to the new entity format

This commit is contained in:
2025-11-02 11:04:19 -07:00
parent 508c4ed32f
commit c5475585d4
69 changed files with 2815 additions and 4038 deletions
+4 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "flix-cli"
version = "0.0.12"
version = "0.0.13"
categories = ["command-line-utilities"]
description = "CLI for interacting with a flix database"
@@ -51,7 +51,9 @@ clap = { workspace = true, features = [
"usage",
] }
futures = { workspace = true }
sea-orm = { workspace = true, features = ["runtime-tokio"] }
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 }
+4
View File
@@ -16,6 +16,10 @@ pub struct Cli {
#[arg(short, long, value_name = "DATABASE", default_value = "./flix.db")]
database: PathBuf,
/// Enable tracing
#[arg(short, long)]
pub trace: bool,
#[command(subcommand)]
command: Command,
}
+7
View File
@@ -28,6 +28,13 @@ async fn main() -> Result<()> {
let client = Client::new(config.tmdb().bearer_token().to_owned());
if cli.trace {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.with_test_writer()
.init();
}
match cli.command() {
Command::Init => exec_init(database_path).await?,
Command::Add { command } => exec_add(client, database_path, command).await?,
+14 -14
View File
@@ -101,7 +101,7 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
flix_id: Set(flix.id),
last_update: Set(Utc::now().date_naive()),
runtime: Set(movie.runtime.into()),
collection: Set(movie.collection.map(|c| c.id)),
collection_id: Set(movie.collection.map(|c| c.id)),
}
.insert(txn)
.await?;
@@ -206,8 +206,8 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
for season in seasons {
entity::info::seasons::ActiveModel {
show: Set(flix.id),
season: Set(season.season_number),
show_id: Set(flix.id),
season_number: Set(season.season_number),
title: Set(season.title),
overview: Set(season.overview),
date: Set(season.air_date),
@@ -229,9 +229,9 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
for (season, episodes) in episodes {
for episode in episodes {
entity::info::episodes::ActiveModel {
show: Set(flix.id),
season: Set(season),
episode: Set(episode.episode_number),
show_id: Set(flix.id),
season_number: Set(season),
episode_number: Set(episode.episode_number),
title: Set(episode.title),
overview: Set(episode.overview),
date: Set(episode.air_date),
@@ -324,8 +324,8 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
.transaction(|txn| {
Box::pin(async move {
entity::info::seasons::ActiveModel {
show: Set(show.flix_id),
season: Set(season_number),
show_id: Set(show.flix_id),
season_number: Set(season_number),
title: Set(season.title),
overview: Set(season.overview),
date: Set(season.air_date),
@@ -345,9 +345,9 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
for episode in episodes {
entity::info::episodes::ActiveModel {
show: Set(show.flix_id),
season: Set(season_number),
episode: Set(episode.episode_number),
show_id: Set(show.flix_id),
season_number: Set(season_number),
episode_number: Set(episode.episode_number),
title: Set(episode.title),
overview: Set(episode.overview),
date: Set(episode.air_date),
@@ -436,9 +436,9 @@ pub async fn add(client: Client, db: &DatabaseConnection, command: Command) -> R
.transaction(|txn| {
Box::pin(async move {
entity::info::episodes::ActiveModel {
show: Set(flix_id),
season: Set(season),
episode: Set(episode_number),
show_id: Set(flix_id),
season_number: Set(season),
episode_number: Set(episode_number),
title: Set(episode.title),
overview: Set(episode.overview),
date: Set(episode.air_date),