Fixed agent UI
All checks were successful
Publish Metadata Agent Image / build-and-push-image (push) Successful in 1m7s
Publish Web Player Image / build-and-push-image (push) Successful in 1m9s
Publish Server Image / build-and-push-image (push) Successful in 2m10s

This commit is contained in:
2026-03-18 04:05:47 +00:00
parent 6e2155d8bd
commit a4010e1173
5 changed files with 639 additions and 403 deletions

View File

@@ -326,6 +326,18 @@ pub async fn approve_and_finalize(
.fetch_one(pool)
.await?;
// Check if track already exists (e.g. previously approved but pending not cleaned up)
let existing: Option<(i64,)> = sqlx::query_as("SELECT id FROM tracks WHERE file_hash = $1")
.bind(&pt.file_hash)
.fetch_optional(pool)
.await?;
if let Some((track_id,)) = existing {
// Already finalized — just mark pending as approved
update_pending_status(pool, pending_id, "approved", None).await?;
return Ok(track_id);
}
let artist_name = pt.norm_artist.as_deref().unwrap_or("Unknown Artist");
let artist_id = upsert_artist(pool, artist_name).await?;
@@ -425,6 +437,16 @@ pub async fn find_album_id(pool: &PgPool, artist_name: &str, album_name: &str) -
Ok(row.map(|r| r.0))
}
/// Fetch pending tracks that need (re-)processing by the LLM pipeline.
pub async fn list_pending_for_processing(pool: &PgPool, limit: i64) -> Result<Vec<PendingTrack>, sqlx::Error> {
sqlx::query_as::<_, PendingTrack>(
"SELECT * FROM pending_tracks WHERE status = 'pending' ORDER BY created_at ASC LIMIT $1"
)
.bind(limit)
.fetch_all(pool)
.await
}
// --- DTOs for insert helpers ---
#[derive(Debug, Default)]