fix: remove duplicate merged code in registerForEvent and cancelRegistration#299
fix: remove duplicate merged code in registerForEvent and cancelRegistration#299Subha12125 wants to merge 2 commits into
Conversation
👋 Thanks for opening a PR, @Subha12125!Your PR has entered the 🎯 EventOne GSSoC PR Review Pipeline.
What happens next
A pipeline status comment will appear below and update automatically as your PR progresses. While you wait
This comment is posted only once. EventOne × GSSoC Automated Pipeline |
❌ PR Format Check — Failed — Please Fix BelowHi @Subha12125! Please fix the issues below before your PR can proceed to mentor review. ❌ Must Fix Before Proceeding❌ Issue #281 is not assigned to you (@Subha12125) — You must be assigned to the issue before submitting a PR.
❌ Issue #281 is not assigned to you (@Subha12125) — You must be assigned to the issue before submitting a PR.
📋 EventOne PR Guidelines (click to expand)Title format — Conventional Commits: Always link an issue: Use a feature branch — never PR directly from Write your own description — AI-generated content = EventOne × GSSoC Pipeline — Stage 1 Automated Check |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors event registration and cancellation flows in registrationController to reduce duplication, improve consistency, and add clearer handling around capacity, refunds, and notifications.
Changes:
- Simplified
registerForEventwith a single flow for QR generation, duplicate handling, live stats emission, and email sending. - Hardened
cancelRegistrationwith existence checks, past-event cancellation prevention, refund-policy handling, and waitlist promotion. - Standardized formatting and logging/error messaging across the controller.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Send email (non-blocking) | ||
| try { | ||
| await sendEmail({ | ||
| to: req.user.email, | ||
| subject: `Registered: ${event.title}`, | ||
| html: `<p>You are registered for ${event.title}.</p>`, | ||
| }); | ||
| } catch (_) {} | ||
| } catch (_) { | ||
| // Ignore email errors to not break registration flow | ||
| } |
62e5d3d to
52eae7f
Compare
|
@Subha12125 is attempting to deploy a commit to the anubhav12302387's projects Team on Vercel. A member of the Team first needs to authorize it. |
Nitya-003
left a comment
There was a problem hiding this comment.
@anubhavxdev Resolved the conflicts. Merge it.
|
@anubhavxdev I raised the PR , so why you assigned to others ???? |
Closes #281
This PR removes mistakenly merged duplicate code from both registerForEvent and cancelRegistration, ensuring that only the correct, atomic logic remains and that event registration and cancellation workflows are reliable and safe for high-concurrency usage.
Changes Made
registerForEventthat used manual capacity checks, which could cause race conditions.elseblocks and brackets that previously caused runtime errors and broken control flow.findOneAndUpdateimplementation for capacity validation, providing robust handling of simultaneous requests.cancelRegistrationlogic, correcting the duplicate conflict and properly defining variables likeeventDate.Why These Changes Were Needed
Previously, two versions of the registration logic were merged together, resulting in unreachable code, errors in registration/cancellation, and reliability issues when multiple users tried to register at the same time. Cancellation was also broken due to missing variable definitions.
How It Was Fixed
emitRegistrationCount().How to Test
npm run dev.node --check src/controllers/registrationController.js(no errors should appear).registeredCountis decremented in the database.Note:
Stage 1 may report a warning about use of a deprecated version of
actions/github-script@v7in the repo workflow, but this is unrelated to this PR’s changes.This version:
Next:
Update your pull request description and title as shown above—these changes will make the automated validation pass, assuming the PR is based on a feature branch and the linked issue (#281) is open and assigned to you.