Coverart queue fetch data #131
+29
-28
@@ -197,12 +197,10 @@ pub mod db {
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(
|
||||
row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
),
|
||||
Ok(row) => Ok(row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
@@ -224,12 +222,10 @@ pub mod db {
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(
|
||||
row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
),
|
||||
Ok(row) => Ok(row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
@@ -358,8 +354,12 @@ pub mod endpoint {
|
||||
pub async fn fetch_coverart_with_data(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Query(params): axum::extract::Query<
|
||||
super::request::fetch_coverart_with_data::Params>,
|
||||
) -> (axum::http::StatusCode, axum::Json<super::response::fetch_coverart_with_data::Response>) {
|
||||
super::request::fetch_coverart_with_data::Params,
|
||||
>,
|
||||
) -> (
|
||||
axum::http::StatusCode,
|
||||
axum::Json<super::response::fetch_coverart_with_data::Response>,
|
||||
) {
|
||||
let mut response = super::response::fetch_coverart_with_data::Response::default();
|
||||
|
||||
match params.id {
|
||||
@@ -375,21 +375,22 @@ pub mod endpoint {
|
||||
}
|
||||
},
|
||||
_ => match params.song_queue_id {
|
||||
Some(song_queue_id) => {
|
||||
match super::db::get_coverart_queue_data_with_song_queue_id(&pool, &song_queue_id)
|
||||
.await
|
||||
{
|
||||
Ok(cover_art_queue) => {
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(cover_art_queue);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
Some(song_queue_id) => match super::db::get_coverart_queue_data_with_song_queue_id(
|
||||
&pool,
|
||||
&song_queue_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(cover_art_queue) => {
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(cover_art_queue);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
},
|
||||
None => {
|
||||
response.message = String::from("No valid id provided");
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
|
||||
+1
-4
@@ -1031,10 +1031,7 @@ mod tests {
|
||||
axum::http::Request::builder()
|
||||
.method(axum::http::Method::GET)
|
||||
.uri(uri)
|
||||
.header(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
"image/jpeg",
|
||||
)
|
||||
.header(axum::http::header::CONTENT_TYPE, "image/jpeg")
|
||||
.body(axum::body::Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user