tsk-196: Moving SongQueue struct (#240)

* tsk-196: Moving SongQueue struct

* tsk-196: Code formatting

* tsk-196: Version bump
This commit was merged in pull request #240.
This commit is contained in:
KD
2025-11-03 13:56:18 -05:00
committed by GitHub
parent a80e21b918
commit 147a50c867
4 changed files with 18 additions and 14 deletions
+15 -11
View File
@@ -11,13 +11,15 @@ pub mod status {
}
}
// TODO: Move this somewhere else at some point
#[derive(Debug, serde::Deserialize, serde::Serialize, sqlx::FromRow, utoipa::ToSchema)]
pub struct SongQueue {
pub id: uuid::Uuid,
pub filename: String,
pub status: String,
pub user_id: uuid::Uuid,
pub mod dbtype {
/// Maps to the songQueue table. Does not contain the data field
#[derive(Debug, serde::Deserialize, serde::Serialize, sqlx::FromRow, utoipa::ToSchema)]
pub struct SongQueue {
pub id: uuid::Uuid,
pub filename: String,
pub status: String,
pub user_id: uuid::Uuid,
}
}
pub async fn insert(
@@ -79,7 +81,9 @@ pub async fn update(
}
}
pub async fn get_most_recent_and_update(pool: &sqlx::PgPool) -> Result<SongQueue, sqlx::Error> {
pub async fn get_most_recent_and_update(
pool: &sqlx::PgPool,
) -> Result<dbtype::SongQueue, sqlx::Error> {
let result = sqlx::query(
r#"
UPDATE "songQueue"
@@ -102,7 +106,7 @@ pub async fn get_most_recent_and_update(pool: &sqlx::PgPool) -> Result<SongQueue
match result {
Ok(row) => {
let user_id_result = row.try_get("user_id");
let song_queue = SongQueue {
let song_queue = dbtype::SongQueue {
id: row
.try_get("id")
.map_err(|_e| sqlx::Error::RowNotFound)
@@ -209,7 +213,7 @@ pub async fn link_user_id(
pub async fn get_song_queue(
pool: &sqlx::PgPool,
id: &uuid::Uuid,
) -> Result<SongQueue, sqlx::Error> {
) -> Result<dbtype::SongQueue, sqlx::Error> {
let result = sqlx::query(
r#"
SELECT id, filename, status, user_id FROM "songQueue" WHERE id = $1
@@ -225,7 +229,7 @@ pub async fn get_song_queue(
match result {
Ok(row) => {
let user_id_result = row.try_get("user_id");
let song_queue = SongQueue {
let song_queue = dbtype::SongQueue {
id: row
.try_get("id")
.map_err(|_e| sqlx::Error::RowNotFound)