Show registration count for non-hosted videos#460
Open
mikewillems wants to merge 6 commits into
Open
Conversation
Will replace with a direct field read of a registrationCount field on the event document, updated on each registration write.
|
Visit the preview URL for this PR (updated for commit c73b697): https://gen-hls-bkc-7627--pr460-mw-feat-external-par-12xucaq6.web.app (expires Thu, 11 Jun 2026 21:07:37 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: eed668cca81618d491d024574a8f8a6003deaa8d |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a server-maintained registration count for events and surfaces it in participant count UI, primarily to avoid exposing non-hosted event participant data while still showing registration totals.
Changes:
- Adds an
Event.registrationCountfield to the data model. - Registers a new Firestore trigger to update registration counts from
event-participants. - Passes and displays registration counts in event card and event page participant widgets.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
firebase/functions/node/main.dart |
Registers the new event participant Firestore trigger. |
firebase/functions/lib/events/on_event_participant.dart |
Adds trigger logic to update event registrationCount. |
data_models/lib/events/event.dart |
Adds the registration count field constant and model property. |
data_models/lib/events/event.freezed.dart |
Generated model updates for registrationCount. |
data_models/lib/events/event.g.dart |
Generated JSON serialization updates for registrationCount. |
client/lib/features/home/presentation/views/home_page_event_card.dart |
Passes registration count into participant display. |
client/lib/features/events/presentation/widgets/participants_list.dart |
Displays registration wording when a registration count is available. |
client/lib/features/events/presentation/widgets/event_participants_list.dart |
Reads registration count from the event provider for event pages. |
client/lib/features/events/presentation/widgets/event_button.dart |
Passes registration count into participant display. |
client/lib/features/events/features/event_page/data/providers/event_provider.dart |
Exposes registration count based on hosted vs non-hosted event behavior. |
Files not reviewed (1)
- data_models/lib/events/event.g.dart: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+48
to
+63
|
|
||
| // Count participants whose status is 'active'. | ||
| final activeDocs = await firestore | ||
| .collection('$eventPath/event-participants') | ||
| .where( | ||
| Participant.kFieldStatus, | ||
| isEqualTo: ParticipantStatus.active.name, | ||
| ) | ||
| .select([]).get(); | ||
|
|
||
| final count = activeDocs.documents.length; | ||
|
|
||
| await firestore.document(eventPath).updateData( | ||
| UpdateData.fromMap({Event.kFieldRegistrationCount: count}), | ||
| ); | ||
|
|
|
|
||
| Widget _buildParticipantCount() { | ||
| final regCount = widget.registrationCount; | ||
| if (widget.event.useParticipantCountEstimate && regCount != null && regCount > 0) { |
Comment on lines
+39
to
+50
| Future<void> _onWrite(Change<DocumentSnapshot> changes) async { | ||
| try { | ||
| // Resolve the participant path regardless of whether this is a create, | ||
| // update, or delete (after may not exist on delete). | ||
| final participantRef = changes.after.exists | ||
| ? changes.after.reference | ||
| : changes.before.reference; | ||
| final eventPath = | ||
| participantRef.path.split('/event-participants/').first; | ||
|
|
||
| // Count participants whose status is 'active'. | ||
| final activeDocs = await firestore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is in this PR?
This PR fixes issue #459
Changes in the codebase
I add a simple cloud function for registration count, gate the showing of the old participant count / member previews on the event being hosted-type, and use the "Registered" wording instead of "Person" or "People" when the registration data is available.
Changes outside the codebase
None.
Testing this PR
[ ] Create hostless or livestream event.
[ ] Register with one account; verify that 1 is shown as the count.
[ ] Navigate to event page (without registering) from another browser; verify that 1 is still shown.
[ ] Join from second browser. Verify that "2" is now shown for both instances.
[ ] Create a hosted event.
[ ] Verify that the functionality is unchanged from before (still shows a participant list) and count.
PR Checklist
[ ] Count calculated via cloud function?
[ ] Cloud function properly permissioned and other permissions unaffected?
[ ] Gated changed functionality on event being non-hosted?
[ ] Registration count read and correctly displayed on cards?
Additional information
Started incorrectly thinking this was a front-end only issue. It is not actually because, although the aggregates (i.e. count) for data are available already, they require permissions that also grant read access to all the user data, which is not an option. So we're making a very simple cloud function for registration count that can be more openly permissioned.
AI tools used (if applicable):
NA