Skip to content

Conversation

@jevinjojo
Copy link

@jevinjojo jevinjojo commented Nov 15, 2025

Issue

Screenshot 2025-11-14 171053

Description

  • redis caching for room view counts
  • detects room types based on module configuration
  • broadcasts user_count_change webSocket events for live

Summary by Sourcery

Update live room view count handling to differentiate stage rooms and video chat rooms, broadcasting either exact or approximate attendee numbers over WebSocket with Redis caching.

New Features:

  • Detect room type from module configuration to decide between actual and approximate attendee counts for live rooms
  • Broadcast user_count_change events with dynamic user counts based on room type

Enhancements:

  • Use approximate_view_number helper for non-stage rooms to display fuzzy counts
  • Maintain Redis-based caching with expiry for room view counts

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR enhances the live room view count logic by caching view counts in Redis with a TTL, detecting stage‐type rooms via module configuration, and broadcasting either an exact or an approximate attendee count over WebSocket based on room type.

Sequence diagram for broadcasting attendee count based on room type

sequenceDiagram
participant RoomModule
participant Redis
participant "Room Logic"
participant WebSocket
RoomModule->>"Room Logic": Provide room.module_config
"Room Logic"->>Redis: Get/Set view count for room
Redis-->>"Room Logic": Return previous view count
"Room Logic"->>"Room Logic": Determine room type (stage or video chat)
"Room Logic"->>"Room Logic": Select count (exact or approximate)
"Room Logic"->>WebSocket: Broadcast user_count_change with selected count
Loading

Class diagram for updated room view count logic

classDiagram
class Room {
  pk: int
  module_config: list
}
class RoomLogic {
  _update_view_count(room, actual_view_count)
}
class Redis {
  getset(key, value)
  expire(key, ttl)
}
class approximate_view_number {
  <<function>>
}
RoomLogic --> Room : uses
RoomLogic --> Redis : caches view count
RoomLogic --> approximate_view_number : uses for video chat rooms
Loading

File-Level Changes

Change Details Files
Apply a TTL to cached room view counts
  • Add redis.expire call when the view count changes
app/eventyay/features/live/modules/room.py
Detect stage rooms from module configuration
  • Define is_stage_room by scanning room.module_config for livestream types
app/eventyay/features/live/modules/room.py
Broadcast dynamic user counts (exact vs approximate)
  • Import approximate_view_number utility
  • Compute users_value as actual count for stage rooms or approximate text otherwise
  • Update WebSocket payload to use users_value instead of always actual_view_count
app/eventyay/features/live/modules/room.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1236 Display the number of attendees currently connected in each active video room.
#1236 Update the attendee count dynamically as participants join or leave the room, without requiring a page refresh.
#1236 Ensure the attendee counter UI element is present and behaves correctly across different video backends (YouTube, Jitsi, BBB), and resets/disappears when the room is inactive.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jevinjojo
Copy link
Author

@mariobehling please review when you have a moment

@mariobehling mariobehling requested a review from Copilot November 15, 2025 20:21
Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

The number should have the same color as the people icon. Alignment should also be the same. The room name should have the same color as the "stage" icon.

Copilot finished reviewing on behalf of mariobehling November 15, 2025 20:24
Copy link
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 implements differentiated attendee count display for video rooms based on room type. Stage rooms (livestream) now display exact numeric counts, while video chat rooms show approximate values ("none", "few", "many") for privacy. The implementation uses Redis caching with a 15-minute expiry and broadcasts user count changes via WebSocket.

Key Changes:

  • Added room type detection logic based on module configuration to differentiate stage rooms from video chat rooms
  • Implemented conditional user count reporting: exact counts for stage rooms, approximate for video chat rooms
  • WebSocket broadcasts now send either integer or string values depending on room type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 199 to 200
# Stage: livestream.youtube, livestream.iframe -> exact numbers
# Video chat: livestream.native, BBB -> "none"/"few"/"many"
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The comment incorrectly classifies 'livestream.native' as a video chat room, but the STAGE_ROOM_MODULE_TYPES constant includes 'livestream.native' as a stage room type (line 57). This creates a contradiction between the comment and the implementation.

Suggested change
# Stage: livestream.youtube, livestream.iframe -> exact numbers
# Video chat: livestream.native, BBB -> "none"/"few"/"many"
# Stage: livestream.youtube, livestream.iframe, livestream.native -> exact numbers
# Video chat: BBB -> "none"/"few"/"many"

Copilot uses AI. Check for mistakes.
for module in room.module_config or []
)

# For stage rooms, use actual count; for stream/video chat rooms, use approximate text
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

[nitpick] This comment is redundant and repeats the logic already explained in the comment block above (lines 198-200). Remove this duplicate explanation.

Suggested change
# For stage rooms, use actual count; for stream/video chat rooms, use approximate text

Copilot uses AI. Check for mistakes.
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.

Bug(video): Reintroduce Display of Attendee Count in Video Rooms on Unified Platform

2 participants