From 5d4352316c66b27650a4b8aa06e643afcd754bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 23 Sep 2026 14:46:10 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(podcast):=20later=20reports?= =?UTF-8?q?=20overwrite=20the=20stored=20source=20statuses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The report UPDATE kept the first non-null sources value (COALESCE old-first), so a job whose early running report stamped pending never learned the terminal ok/skipped statuses — live result doors showed pending forever. New value now wins; a report that omits sources still keeps the previous one. Regression pin: running report carries pending, the done report's statuses must survive to the result door. Local-Gate: 990f3981b70f8f451ad75bc1f9688a2e3cbf2897 (1518 passed, 450s) --- ...1e8f70384e5a262b9111183394b54c76d9412c72fa.json} | 4 ++-- src/db/podcast_job.rs | 2 +- tests/podcast.rs | 13 +++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) rename .sqlx/{query-6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8.json => query-211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa.json} (97%) diff --git a/.sqlx/query-6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8.json b/.sqlx/query-211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa.json similarity index 97% rename from .sqlx/query-6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8.json rename to .sqlx/query-211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa.json index 31e5fb0..b823768 100644 --- a/.sqlx/query-6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8.json +++ b/.sqlx/query-211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), sources = COALESCE(sources, $9::jsonb), updated_at = $10 WHERE id = $1 AND state = $2 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, sources AS \"sources: Json\", state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", + "query": "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), sources = COALESCE($9::jsonb, sources), updated_at = $10 WHERE id = $1 AND state = $2 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", source_id, format, transcript, sources AS \"sources: Json\", state AS \"state: PodcastJobState\", stage, progress, error_code, audio_key, audio_name, audio_type, audio_bytes, duration_secs, eta_secs, created_at AS \"created_at: Timestamp\", updated_at AS \"updated_at: Timestamp\"", "describe": { "columns": [ { @@ -237,5 +237,5 @@ false ] }, - "hash": "6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8" + "hash": "211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa" } diff --git a/src/db/podcast_job.rs b/src/db/podcast_job.rs index ab6106f..3b61348 100644 --- a/src/db/podcast_job.rs +++ b/src/db/podcast_job.rs @@ -203,7 +203,7 @@ pub async fn report( PodcastJob, "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \ format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), \ - sources = COALESCE(sources, $9::jsonb), updated_at = $10 \ + sources = COALESCE($9::jsonb, sources), updated_at = $10 \ WHERE id = $1 AND state = $2 \ RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \ source_id, format, transcript, sources AS \"sources: Json\", state AS \"state: PodcastJobState\", stage, progress, error_code, \ diff --git a/tests/podcast.rs b/tests/podcast.rs index 5cc497e..2619572 100644 --- a/tests/podcast.rs +++ b/tests/podcast.rs @@ -854,14 +854,11 @@ async fn the_result_door_exposes_the_reported_sources() { let (note, _key) = note_with_pdf(&app, &db).await; let job_id = submit_job(&app, &cookie, ¬e).await; - assert_report_stored( - &capability_call( - &service.conn, - report_frame(&job_id, ¬e, &user, "running", "tts", 0.25), - ) - .await, - &job_id, - ); + let mut running = report_frame(&job_id, ¬e, &user, "running", "tts", 0.25); + running["payload"]["sources"] = json!([ + { "key": "019732e3-7b00-7000-8000-00000000beef", "name": "tanim.pdf", "status": "pending" }, + ]); + assert_report_stored(&capability_call(&service.conn, running).await, &job_id); let bytes = episode_bytes(); let answer = blob_upload(