Formatting

This commit is contained in:
kdeng00
2025-04-29 21:37:24 -04:00
parent fe818fc154
commit 07eead8b92
2 changed files with 56 additions and 55 deletions
+41 -43
View File
@@ -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))
}
},
}
}
}
+15 -12
View File
@@ -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);
}