forge
Explore
Log in

Don't you dare go Hollow

Later reports overwrite the stored source statuses

Browse files at this commit

5d4352316c66b27650a4b8aa06e643afcd754bddAhmet Kaan GümüşParent: 979d53f
  • fix
    • later reports overwrite the stored source statuses
Show full message
🐛 fix(podcast): later reports overwrite the stored source statuses

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)
.sqlx/query-6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8.json → .sqlx/query-211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa.jsonrenamed+2 -2
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "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<Value>\", 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\"",3+ "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<Value>\", 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\"",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -237,5 +237,5 @@
237 false237 false
238 ]238 ]
239 },239 },
240- "hash": "6b6ca993e9600caf8a4066432a7583be29811979fcfa869677c8dbbe5d19e2a8"240+ "hash": "211337e4e9c9056c653e8e1e8f70384e5a262b9111183394b54c76d9412c72fa"
241 }241 }
src/db/podcast_job.rsmodified+1 -1
@@ -203,7 +203,7 @@ pub async fn report(
203 PodcastJob,203 PodcastJob,
204 "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \204 "UPDATE podcast_job SET state = $3, stage = $4, progress = $5, error_code = $6, \
205 format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), \205 format = COALESCE(format, $7::text), transcript = COALESCE(transcript, $8::text), \
206- sources = COALESCE(sources, $9::jsonb), updated_at = $10 \206+ sources = COALESCE($9::jsonb, sources), updated_at = $10 \
207 WHERE id = $1 AND state = $2 \207 WHERE id = $1 AND state = $2 \
208 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \208 RETURNING id AS \"id: PodcastJobId\", user_id AS \"user_id: UserId\", \
209 source_id, format, transcript, sources AS \"sources: Json<Value>\", state AS \"state: PodcastJobState\", stage, progress, error_code, \209 source_id, format, transcript, sources AS \"sources: Json<Value>\", state AS \"state: PodcastJobState\", stage, progress, error_code, \
tests/podcast.rsmodified+5 -8
@@ -854,14 +854,11 @@ async fn the_result_door_exposes_the_reported_sources() {
854 let (note, _key) = note_with_pdf(&app, &db).await;854 let (note, _key) = note_with_pdf(&app, &db).await;
855 let job_id = submit_job(&app, &cookie, &note).await;855 let job_id = submit_job(&app, &cookie, &note).await;
856 856
857- assert_report_stored(857+ let mut running = report_frame(&job_id, &note, &user, "running", "tts", 0.25);
858- &capability_call(858+ running["payload"]["sources"] = json!([
859- &service.conn,859+ { "key": "019732e3-7b00-7000-8000-00000000beef", "name": "tanim.pdf", "status": "pending" },
860- report_frame(&job_id, &note, &user, "running", "tts", 0.25),860+ ]);
861- )861+ assert_report_stored(&capability_call(&service.conn, running).await, &job_id);
862- .await,
863- &job_id,
864- );
865 862
866 let bytes = episode_bytes();863 let bytes = episode_bytes();
867 let answer = blob_upload(864 let answer = blob_upload(