diff --git a/migrations/20230426221940_init.up.sql b/migrations/20230426221940_init.up.sql index f94e598..5cf418d 100644 --- a/migrations/20230426221940_init.up.sql +++ b/migrations/20230426221940_init.up.sql @@ -18,7 +18,7 @@ create table if not exists witches ( -- table of things to watch create table if not exists watches ( id blob not null primary key, - typ int not null, -- enum for movie or tv show or whatev + kind int not null, -- enum for movie or tv show or whatev title text not null, metadata_url text, -- possible url for imdb or other metadata-esque site to show the user length int, diff --git a/src/lib.rs b/src/lib.rs index c07ca09..9bf07e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,9 +38,7 @@ pub async fn app(db_pool: sqlx::SqlitePool, session_secret: &[u8]) -> axum::Rout use generic_handlers::{handle_slash, handle_slash_redir}; use login::{get_login, get_logout, post_login, post_logout}; use signup::{get_create_user, handle_signup_success, post_create_user}; - use watches::handlers::{ - get_search_watch, get_watches, post_add_watch, post_search_watch, put_add_watch, - }; + use watches::handlers::{get_search_watch, get_watches, post_add_watch}; axum::Router::new() .route("/", get(handle_slash).post(handle_slash)) @@ -51,13 +49,8 @@ pub async fn app(db_pool: sqlx::SqlitePool, session_secret: &[u8]) -> axum::Rout .route("/watches", get(get_watches)) .route("/watch", get(get_watch)) .route("/watch/:id", get(get_watch)) - .route("/search", get(get_search_watch).post(post_search_watch)) - .route( - "/add", - get(get_search_watch) - .put(put_add_watch) - .post(post_add_watch), - ) + .route("/search", get(get_search_watch)) + .route("/add", get(get_search_watch).post(post_add_watch)) .fallback(handle_slash_redir) .layer(middleware::from_fn_with_state( db_pool.clone(), diff --git a/src/watches/handlers.rs b/src/watches/handlers.rs index d220ee5..910181f 100644 --- a/src/watches/handlers.rs +++ b/src/watches/handlers.rs @@ -74,11 +74,8 @@ impl Default for SearchQuery { // handlers //-************************************************************************ -/// Add a new Watch to the whole system (also adds to your watchlist) -pub async fn put_add_watch() {} - -/// Add a Watch to your watchlist -pub async fn post_add_watch() {} +/// Add a Watch to your watchlist (side effects system-add if missing) +pub async fn post_add_watch() -> impl IntoResponse {} /// A single Watch pub async fn get_watch( @@ -146,4 +143,5 @@ pub async fn get_search_watch( } } -pub async fn post_search_watch() {} + +} diff --git a/src/watches/mod.rs b/src/watches/mod.rs index 2dd680b..ecfc31a 100644 --- a/src/watches/mod.rs +++ b/src/watches/mod.rs @@ -7,7 +7,7 @@ pub mod templates; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, sqlx::Type, )] -#[repr(i32)] +#[repr(i64)] pub enum ShowKind { Movie = 0, Series = 1, @@ -18,7 +18,14 @@ pub enum ShowKind { impl std::fmt::Display for ShowKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - todo!() + let repr = match self { + Self::Movie => "movie", + Self::Series => "series", + Self::LimitedSeries => "limited series", + Self::Short => "short form", + Self::Unknown => "unknown", + }; + write!(f, "{repr}") } } @@ -28,8 +35,8 @@ impl Default for ShowKind { } } -impl From for ShowKind { - fn from(value: i32) -> Self { +impl From for ShowKind { + fn from(value: i64) -> Self { match value { 0 => Self::Movie, 1 => Self::Series, @@ -59,7 +66,7 @@ pub struct Watch { pub kind: ShowKind, pub title: String, pub metadata_url: Option, - pub length: Option, + pub length: Option, pub release_date: Option, added_by: Uuid, // this shouldn't be exposed to randos created_at: i64,