Update song queue status #129

Merged
kdeng00 merged 7 commits from update_song_queue_status into v0.2 2025-05-20 20:42:34 -04:00
Showing only changes of commit 2a273a52c5 - Show all commits
+19 -10
View File
@@ -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 { mod song_queue {
use sqlx::Row; 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)] #[derive(Debug, serde::Serialize, sqlx::FromRow)]
pub struct InsertedData { pub struct InsertedData {
pub id: uuid::Uuid, pub id: uuid::Uuid,
@@ -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();