Skip to content

Fix: Competition brackets, account deletion cascade, notifications, a… - #1915

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
designsage8:fix/backend-competition-account-notifications-export
Sep 28, 2026
Merged

Olowodarey merged 1 commit into
Arena1X:mainfrom
designsage8:fix/backend-competition-account-notifications-export

Conversation

@designsage8

Copy link
Copy Markdown
Contributor

Backend Fixes: Competition Brackets, Account Deletion, Notifications, and Export Status

This PR addresses four backend issues related to competition bracket generation, account deletion cascade, notification delivery, and export status polling.

Changes

Task #1836: Competition Bracket Generation for Odd Participant Counts

File: backend/src/competitions/competitions.service.spec.ts

Changes:

  • Added test to verify bracket generation with exactly one bye for 5 participants
  • Added test to verify bracket generation with zero byes for power-of-two participant count (8)
  • Tests confirm that bye recipients automatically advance as winners without manual result submission

Acceptance Criteria:

  • ✅ generateBracket with 5 participants produces a valid bracket with exactly one first-round bye
  • ✅ The bye-recipient participant advances to round 2 without a submitted match result
  • ✅ generateBracket with a power-of-two participant count (e.g., 8) produces a bracket with zero byes

Task #1833: Account Deletion Cascade to Dependent Records

Files:

  • backend/src/account/account.service.ts
  • backend/src/account/account.service.spec.ts

Changes:

  • Enhanced deleteAccount to explicitly delete all dependent records within the same transaction:
    • Bookmarks (user_bookmarks)
    • Follows (both as follower and following in user_follows)
    • API keys (api_keys)
    • Notification preferences (notification_preferences)
  • Added idempotency check: if account is already deleted (deleted_at is set), return without error
  • Added comprehensive test coverage for:
    • Deletion of all dependent records within transaction
    • Idempotency when called twice for the same account
    • Transaction rollback on failure

Acceptance Criteria:

  • ✅ deleteAccount removes the user's bookmarks, follows, and API keys within the same transaction
  • ✅ deleteAccount for an already-deleted address does not throw an unhandled error
  • ✅ A failure partway through deleteAccount rolls back rather than leaving a partially-deleted account

Task #1837: Competition Cancellation Notification Delivery to All Participants

File: backend/src/competitions/competitions.service.spec.ts

Changes:

  • Added test to verify exactly one notification is sent per currently-joined participant
  • Added test to verify participants who left before cancellation do not receive notifications
  • Existing implementation already correctly queries the current participant list at cancellation time

Acceptance Criteria:

  • ✅ notifyParticipantsOfCancellation sends exactly one notification per currently-joined participant
  • ✅ A participant removed via leave() before cancellation does not receive a cancellation notification
  • ✅ cancel() on an already-cancelled competition does not re-trigger notifications a second time (existing behavior via ConflictException)

Task #1834: Account Export Status Polling for a Nonexistent Request

File: backend/src/account/account.service.spec.ts

Changes:

  • Added test to verify getExportStatus returns not-found for random/nonexistent request IDs
  • Added test to verify getExportStatus rejects requests for valid job IDs belonging to different users
  • Added test to verify getExportStatus returns correct status for valid in-progress requests of the caller
  • Existing implementation already correctly validates user ownership via job.user_id !== userId check

Acceptance Criteria:

  • ✅ getExportStatus for a random/nonexistent request ID returns not-found, not a thrown 500
  • ✅ getExportStatus for a valid request ID belonging to a different user is rejected/hidden
  • ✅ getExportStatus for a valid, in-progress request of the caller's own returns the correct in-progress state

Testing

All changes include comprehensive unit test coverage. The existing service implementations were already correct for tasks #1837 and #1834, so only test coverage was added to enforce the behavior. Tasks #1833 and #1836 required both implementation improvements and test coverage.

Checklist

  • Code follows project style guidelines
  • Tests added/updated for all changes
  • No breaking changes to existing APIs
  • Transaction safety ensured for account deletion
  • Idempotency ensured for account deletion

Closes #1836, Closes #1833, Closes #1837, Closes #1834

…nd export status

- Add tests for bracket generation with odd participant counts (Arena1X#1836)
- Enhance account deletion to cascade delete dependent records (Arena1X#1833)
- Add tests for cancellation notification delivery to all participants (Arena1X#1837)
- Add tests for export status polling for nonexistent requests (Arena1X#1834)

Closes Arena1X#1836, Arena1X#1833, Arena1X#1837, Arena1X#1834
@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@designsage8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Sep 28, 2026 4:40pm UTC

@Olowodarey
Olowodarey merged commit 070724f into Arena1X:main Sep 28, 2026
1 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 535b208a Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants