Skip to content

Show registration count for non-hosted videos#460

Open
mikewillems wants to merge 6 commits into
stagingfrom
mw/feat/external-participant-count
Open

Show registration count for non-hosted videos#460
mikewillems wants to merge 6 commits into
stagingfrom
mw/feat/external-participant-count

Conversation

@mikewillems
Copy link
Copy Markdown
Collaborator

@mikewillems mikewillems commented May 28, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

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

@mikewillems mikewillems marked this pull request as ready for review May 28, 2026 21:13
Copilot AI review requested due to automatic review settings May 28, 2026 21:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.registrationCount field 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
@mikewillems mikewillems changed the title Mw/feat/external participant count Show registration count for non-hosted videos May 28, 2026
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.

2 participants