tsk-196: Moving SongQueue struct #240
Generated
+1
-1
@@ -964,7 +964,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus"
|
||||
version = "0.3.22"
|
||||
version = "0.3.23"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-extra",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "icarus"
|
||||
version = "0.3.22"
|
||||
version = "0.3.23"
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ pub mod response {
|
||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<crate::repo::queue::song::SongQueue>,
|
||||
pub data: Vec<crate::repo::queue::song::dbtype::SongQueue>,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ pub mod status {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move this somewhere else at some point
|
||||
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,
|
||||
@@ -19,6 +20,7 @@ pub struct SongQueue {
|
||||
pub status: String,
|
||||
pub user_id: uuid::Uuid,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn insert(
|
||||
pool: &sqlx::PgPool,
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user