From 2a273a52c546d9c464a2360f0e2db47a0a7fc4ab Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 20 May 2025 19:34:31 -0400 Subject: [PATCH] Changes to status definition --- src/callers/song.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/callers/song.rs b/src/callers/song.rs index 0f4872d..0fcb004 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -27,16 +27,25 @@ pub mod response { } } +pub mod status { + pub const PENDING: &str = "pending"; + // Will be used later on + pub const PROCESSING: &str = "processing"; + pub const DONE: &str = "done"; + + pub async fn is_valid(status: &str) -> bool { + if status == PENDING || status == PROCESSING || status == DONE { + true + } else { + false + } + } +} + + mod song_queue { use sqlx::Row; - pub mod status { - pub const PENDING: &str = "pending"; - // Will be used later on - pub const PROCESSING: &str = "processing"; - pub const _DONE: &str = "done"; - } - #[derive(Debug, serde::Serialize, sqlx::FromRow)] pub struct InsertedData { pub id: uuid::Uuid, @@ -96,8 +105,8 @@ mod song_queue { RETURNING id, filename, status; "#, ) - .bind(status::PROCESSING) - .bind(status::PENDING) + .bind(super::status::PROCESSING) + .bind(super::status::PENDING) .fetch_one(pool) .await .map_err(|e| { @@ -186,7 +195,7 @@ pub mod endpoint { &pool, &raw_data, &file_name, - &song_queue::status::PENDING.to_string(), + &super::status::PENDING.to_string(), ) .await .unwrap();