From 07eead8b92ee99c9aa39e6859d9988225728b693 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Tue, 29 Apr 2025 21:37:24 -0400 Subject: [PATCH] Formatting --- src/callers/metadata.rs | 84 ++++++++++++++++++++--------------------- src/main.rs | 27 +++++++------ 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/callers/metadata.rs b/src/callers/metadata.rs index 7e4324e..253023f 100644 --- a/src/callers/metadata.rs +++ b/src/callers/metadata.rs @@ -171,29 +171,30 @@ pub mod metadata_queue { }); match result { - Ok(row) => - { - let data: serde_json::Value = row.try_get("metadata").map_err(|_e| sqlx::Error::RowNotFound).unwrap(); + Ok(row) => { + let data: serde_json::Value = row + .try_get("metadata") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(); Ok(MetadataQueue { - id: row - .try_get("id") - .map_err(|_e| sqlx::Error::RowNotFound) - .unwrap(), - metadata: data, - created_at: row - .try_get("created_at") - .map_err(|_e| sqlx::Error::RowNotFound) - .unwrap(), - song_queue_id: row - .try_get("song_queue_id") - .map_err(|_e| sqlx::Error::RowNotFound) - .unwrap(), + id: row + .try_get("id") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), + metadata: data, + created_at: row + .try_get("created_at") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), + song_queue_id: row + .try_get("song_queue_id") + .map_err(|_e| sqlx::Error::RowNotFound) + .unwrap(), }) - }, + } Err(_err) => Err(sqlx::Error::RowNotFound), } } - } pub mod endpoint { @@ -235,8 +236,23 @@ pub mod endpoint { Some(id) => { println!("Something works {:?}", id); - - match super::metadata_queue::get_with_id(&pool, &id).await { + match super::metadata_queue::get_with_id(&pool, &id).await { + Ok(item) => { + response.message = String::from("Successful"); + response.data.push(item); + (StatusCode::OK, Json(response)) + } + Err(err) => { + response.message = err.to_string(); + (StatusCode::BAD_REQUEST, Json(response)) + } + } + } + _ => match params.song_queue_id { + Some(song_queue_id) => { + println!("Song queue Id is probably not nil"); + match super::metadata_queue::get_with_song_queue_id(&pool, &song_queue_id).await + { Ok(item) => { response.message = String::from("Successful"); response.data.push(item); @@ -247,30 +263,12 @@ pub mod endpoint { (StatusCode::BAD_REQUEST, Json(response)) } } - } - _ => { - match params.song_queue_id { - Some(song_queue_id) => { - println!("Song queue Id is probably not nil"); - match super::metadata_queue::get_with_song_queue_id(&pool, &song_queue_id).await - { - Ok(item) => { - response.message = String::from("Successful"); - response.data.push(item); - (StatusCode::OK, Json(response)) - } - Err(err) => { - response.message = err.to_string(); - (StatusCode::BAD_REQUEST, Json(response)) - } - } - } - None => { - println!("What is going on?"); - (StatusCode::BAD_REQUEST, Json(response)) - } } - } + None => { + println!("What is going on?"); + (StatusCode::BAD_REQUEST, Json(response)) + } + }, } } } diff --git a/src/main.rs b/src/main.rs index a52323e..9096227 100644 --- a/src/main.rs +++ b/src/main.rs @@ -565,18 +565,21 @@ mod tests { let id = resp.data[0]; let uri = format!("{}?id={}", crate::callers::endpoints::QUEUEMETADATA, id); - match app.clone().oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - // .uri(crate::callers::endpoints::QUEUEMETADATA) - .uri(crate::callers::endpoints::QUEUEMETADATA) - .header(axum::http::header::CONTENT_TYPE, "application/json") - // .body(axum::body::Body::from(new_payload.to_string())) - .body(axum::body::Body::empty()) - .unwrap(), - ).await { - Ok(response) => { - } + match app + .clone() + .oneshot( + axum::http::Request::builder() + .method(axum::http::Method::GET) + // .uri(crate::callers::endpoints::QUEUEMETADATA) + .uri(crate::callers::endpoints::QUEUEMETADATA) + .header(axum::http::header::CONTENT_TYPE, "application/json") + // .body(axum::body::Body::from(new_payload.to_string())) + .body(axum::body::Body::empty()) + .unwrap(), + ) + .await + { + Ok(response) => {} Err(err) => { assert!(false, "Error: {:?}", err); }