use std::{ffi::OsString, time::Duration}; use clap::Parser; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use witch_watch::{ get_db_pool, import_utils::{add_omega_watches, ImportMovieOmega}, }; const MOVIE_QUERY: &str = "select * from movies order by random() limit 10000"; #[derive(Debug, Parser)] struct Cli { #[clap(long, short)] pub db_path: OsString, } #[tokio::main] async fn main() { let cli = Cli::parse(); let path = cli.db_path; let opts = SqliteConnectOptions::new().filename(&path).read_only(true); let movie_db = SqlitePoolOptions::new() .idle_timeout(Duration::from_secs(90)) .connect_with(opts) .await .expect("could not open movies db"); let ww_db = get_db_pool().await; let movies: Vec = sqlx::query_as(MOVIE_QUERY) .fetch_all(&movie_db) .await .unwrap(); add_omega_watches(&ww_db, movies).await; }