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