fix(subscriber): await season status saves when approving TV requests#2743
fix(subscriber): await season status saves when approving TV requests#2743dougrathbone wants to merge 1 commit intoseerr-team:developfrom
Conversation
When a TV MediaRequest was approved, child SeasonRequest statuses were updated via forEach without awaiting the save calls, making them fire-and-forget. Any code reading season statuses immediately after approval (notification logic, media status checks) could observe stale PENDING values. The declined path in the same function already used for...of with await correctly. This aligns the approved path to the same pattern. Adds tests for both paths to confirm status changes are persisted to the database before updateParentStatus returns.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change adds test coverage for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
When a TV
MediaRequestis approved,updateParentStatusiterates itsSeasonRequestchildren and marks each oneAPPROVED. The saves were issued viaforEachwithoutawait, making them fire-and-forget. Anything reading season statuses synchronously after approval -- notification logic, media status checks -- could observe stalePENDINGvalues.The declined path in the same function already does this correctly using
for...ofwithawait(introduced in the declined-request season-reset logic). The approved path was inconsistent with it.Before:
After (matching the pattern used in the declined branch):
Test plan
MediaRequestSubscriber.updateParentStatus-- persists APPROVED status to all child SeasonRequests in the databaseMediaRequestSubscriber.updateParentStatus-- persists DECLINED status to all child SeasonRequests in the database (documents the existing correct behaviour as a regression guard)Both tests use the real SQLite test database via
setupTestDb(), consistent with the project's existing test approach inserver/routes/.AI disclosure: AI was used for code completion. All testing and interaction with the codebase was done manually.
Summary by CodeRabbit
Bug Fixes
Tests