Skip to content

Implement Event capacity management and Waitlist functionality. #194

Merged
mubarak23 merged 4 commits into
mubarak23:mainfrom
codebestia:feat/event-capacity-management
Jun 7, 2025
Merged

Implement Event capacity management and Waitlist functionality. #194
mubarak23 merged 4 commits into
mubarak23:mainfrom
codebestia:feat/event-capacity-management

Conversation

@codebestia

Copy link
Copy Markdown
Contributor

Summary

This pull request introduces event capacity management and waitlist functionality to the ChainEvents contract. It allows event owners to set and update the maximum capacity for events, enforces capacity limits during registration, and enables users to join a waitlist when an event is full. Additionally, it provides mechanisms to automatically register users from the waitlist when spots become available.


Key Changes

1. Event Capacity Management

  • Added max_capacity to EventDetails struct to track the maximum number of attendees per event.
  • Default capacity is set via DEFAULT_EVENT_MAX_CAPACITY.
  • New function update_event_max_capacity allows event owners to update the capacity of their events (with checks for validity and event state).
  • Emits EventCapacityUpdated event when capacity is changed.

2. Waitlist Functionality

  • Waitlist storage: Added mappings for waitlist, waitlist_position, and joined_waitlist to track waitlisted users per event.
  • New function join_event_waitlist: Allows users to join the waitlist if the event is full and they are not already registered or on the waitlist.
  • Emits JoinEventWaitlist event when a user joins the waitlist.
  • Automatic registration from waitlist: When a user unregisters from an event, the next user on the waitlist is automatically registered.

3. Registration Logic Updates

  • Registration now checks max_capacity before allowing a user to register.
  • Unregistration triggers waitlist processing to fill vacated spots.

4. Interface & Event Updates

  • Updated IEvent interface to include new functions for capacity and waitlist management.
  • New events: EventCapacityUpdated and JoinEventWaitlist for better indexer support and transparency.

5. Error Handling

  • New error messages for capacity and waitlist-related conditions (e.g., EVENT_IS_FULL, ALREADY_JOINED_WAITLIST, etc.).

Motivation

  • Scalability: Enables event organizers to manage attendee limits efficiently.
  • User Experience: Provides a fair mechanism for users to join popular events via a waitlist.
  • Automation: Reduces manual intervention by automatically filling spots from the waitlist.

Backward Compatibility

  • Existing event creation and registration flows remain unchanged for events that do not reach capacity.
  • New features are additive and do not break existing interfaces.

Additional Notes

  • All new functions are documented and emit relevant events for off-chain tracking.
  • The waitlist is implemented as a FIFO queue per event.
  • Only event owners can update event capacity, and only when the event is closed.

Related Issue

Closes #192

@codebestia

Copy link
Copy Markdown
Contributor Author

GM @mubarak23
Please review the changes and provide feedback.

@mubarak23

Copy link
Copy Markdown
Owner

@codebestia i will review this PR tonight

@codebestia

Copy link
Copy Markdown
Contributor Author

GM @mubarak23
Does this PR meet the requirements of the issue?

@mubarak23
mubarak23 self-requested a review June 7, 2025 08:12

@mubarak23 mubarak23 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFGM

@mubarak23

Copy link
Copy Markdown
Owner

@codebestia excellent work

@mubarak23
mubarak23 merged commit 1ccd437 into mubarak23:main Jun 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Event Capacity Management and Waitlist Functionality

2 participants