mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
## Summary Follow-up to #842. Operational correctness fixes to `backend/scripts/backfill_original_audio.py`, found while running the original-audio backfill against production (**344 jobs restored, 0 errors**). As merged, the script silently did nothing and would have mis-routed private tracks. ## Changes - **Date filter:** `created_at` is stored as an ISO **string** in Firestore, so the server-side `created_after`/`created_before` datetime filters matched nothing ("Considering 0 jobs"). Now fetches completed jobs (ordered desc) and filters the date window in Python; default fetch limit raised to 5000 to bound the lookback. - **Private-track path:** uses `get_effective_distribution_for_job()` for the Dropbox path, so private (`NOMADNP`) tracks resolve to the **NonPublished** path instead of the job's stored public `dropbox_path` (was skipping 130+ private tracks as "folder missing"). - **Folder guard:** only uploads into a track folder that **already exists** (new `skip-folder-missing`), so drifted brand/artist/title naming can't create an orphan folder with a lone FLAC. - **Env filter:** filters environment in Python (avoids needing a 3-field composite Firestore index); `--env` now defaults to none (test jobs skip naturally — no brand/Dropbox folder). - **Resilience:** per-job planning errors are counted, not fatal. ## Testing - [x] 8 planner unit tests pass (`test_backfill_original_audio.py`), incl. new `skip-folder-missing` case - [x] Proven end-to-end in production: 344 original-audio files restored to the correct public/private Dropbox folders, idempotent re-run confirmed (already-present skipped, transient errors retried clean) ## Review - [x] Validated by actually executing against prod; script-only change, no runtime/service impact @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>