Coverart queue #259

Merged
phoenix merged 10 commits from coverart_queue into main 2026-08-14 08:42:38 -04:00
2 changed files with 33 additions and 16 deletions
Showing only changes of commit 6508c36c4b - Show all commits
+17 -3
View File
@@ -205,7 +205,8 @@ pub mod endpoint {
.await .await
{ {
Ok(id) => { Ok(id) => {
match repo::data::insert( println!("Inserting queued data");
match repo::data::queue::coverart::insert(
&pool, &pool,
&file_path, &file_path,
&lr.config.bucket, &lr.config.bucket,
@@ -215,6 +216,7 @@ pub mod endpoint {
.await .await
{ {
Ok(_id) => { Ok(_id) => {
println!("Successfully did it");
response.message = String::from("Successful"); response.message = String::from("Successful");
response.data.push(id); response.data.push(id);
(axum::http::StatusCode::OK, axum::Json(response)) (axum::http::StatusCode::OK, axum::Json(response))
@@ -363,9 +365,20 @@ 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::Path(id): axum::extract::Path<uuid::Uuid>, axum::extract::Path(coverart_queue_id): axum::extract::Path<uuid::Uuid>,
) -> (axum::http::StatusCode, axum::response::Response) { ) -> (axum::http::StatusCode, axum::response::Response) {
match repo::data::queue::coverart::get_with_coverart_queue_id(&pool, &id).await { match repo::coverart::get_coverart_queue_with_id(&pool, &coverart_queue_id).await {
Ok(c) => {
println!("C: {c:?}");
}
Err(err) => {
eprintln!("Error: {err:?}");
eprintln!("This is wrong");
}
}
match repo::data::queue::coverart::get_with_coverart_queue_id(&pool, &coverart_queue_id)
.await
{
Ok((_id, file_key, _bucket, _region, _)) => { Ok((_id, file_key, _bucket, _region, _)) => {
let lab_config = crate::util::maze::get_config(); let lab_config = crate::util::maze::get_config();
let lr = labyrinth::Labyrinth { config: lab_config }; let lr = labyrinth::Labyrinth { config: lab_config };
@@ -421,6 +434,7 @@ pub mod endpoint {
} }
} }
Err(err) => { Err(err) => {
eprintln!("Record not found");
eprintln!("Error: {err:?}"); eprintln!("Error: {err:?}");
( (
axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::http::StatusCode::INTERNAL_SERVER_ERROR,
+16 -13
View File
@@ -109,21 +109,24 @@ pub mod queue {
coverart_queue_id: &uuid::Uuid, coverart_queue_id: &uuid::Uuid,
) -> Result<uuid::Uuid, sqlx::Error> { ) -> Result<uuid::Uuid, sqlx::Error> {
match sqlx::query( match sqlx::query(
r#" r#"
INSERT INTO "coverartQueueData" (file_key, bucket, region, coverart_queue_id) VALUES($1, $2, $3, $4) RETURNING id; INSERT INTO "coverartQueueData" (file_key, bucket, region, coverart_queue_id)
VALUES($1, $2, $3, $4) RETURNING id;
"#, "#,
) )
.bind(file_key) .bind(file_key)
.bind(bucket) .bind(bucket)
.bind(region) .bind(region)
.bind(coverart_queue_id) .bind(coverart_queue_id)
.fetch_one(pool).await { .fetch_one(pool)
Ok(row) => { .await
let id: uuid::Uuid = row.try_get("id")?; {
Ok(id) Ok(row) => {
} let id: uuid::Uuid = row.try_get("id")?;
Err(_err) => Err(sqlx::Error::RowNotFound), Ok(id)
} }
Err(_err) => Err(sqlx::Error::RowNotFound),
}
} }
pub async fn update_file_key( pub async fn update_file_key(