Changes to status definition

This commit is contained in:
kdeng00
2025-05-20 19:34:31 -04:00
parent b1f5c5f604
commit 2a273a52c5
+17 -8
View File
@@ -27,15 +27,24 @@ pub mod response {
} }
} }
mod song_queue { pub mod status {
use sqlx::Row;
pub mod status {
pub const PENDING: &str = "pending"; pub const PENDING: &str = "pending";
// Will be used later on // Will be used later on
pub const PROCESSING: &str = "processing"; pub const PROCESSING: &str = "processing";
pub const _DONE: &str = "done"; 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;
#[derive(Debug, serde::Serialize, sqlx::FromRow)] #[derive(Debug, serde::Serialize, sqlx::FromRow)]
pub struct InsertedData { pub struct InsertedData {
@@ -96,8 +105,8 @@ mod song_queue {
RETURNING id, filename, status; RETURNING id, filename, status;
"#, "#,
) )
.bind(status::PROCESSING) .bind(super::status::PROCESSING)
.bind(status::PENDING) .bind(super::status::PENDING)
.fetch_one(pool) .fetch_one(pool)
.await .await
.map_err(|e| { .map_err(|e| {
@@ -186,7 +195,7 @@ pub mod endpoint {
&pool, &pool,
&raw_data, &raw_data,
&file_name, &file_name,
&song_queue::status::PENDING.to_string(), &super::status::PENDING.to_string(),
) )
.await .await
.unwrap(); .unwrap();