Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: execute VideoConference statistics count queries in parallel#39248

Open
Khizarshah01 wants to merge 1 commit intoRocketChat:developfrom
Khizarshah01:refactor/parallelize-video-conference-statistics
Open

refactor: execute VideoConference statistics count queries in parallel#39248
Khizarshah01 wants to merge 1 commit intoRocketChat:developfrom
Khizarshah01:refactor/parallelize-video-conference-statistics

Conversation

@Khizarshah01
Copy link
Contributor

@Khizarshah01 Khizarshah01 commented Mar 2, 2026

Proposed changes (including videos or screenshots)

Refactors getStatistics() to execute the 7 independent countByTypeAndStatus queries concurrently using Promise.all() instead of sequential await calls.

Since the queries are independent and read-only, running them in parallel reduces total latency without changing behavior.

Issue(s)

Fixes #39247

Further comments

no functional changes

Summary by CodeRabbit

  • Performance Improvements
    • Video conference statistics are now gathered concurrently, reducing latency when loading usage metrics and improving responsiveness.

@Khizarshah01 Khizarshah01 requested a review from a team as a code owner March 2, 2026 15:57
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 2, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

⚠️ No Changeset found

Latest commit: a141a00

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc135ad and a141a00.

📒 Files selected for processing (1)
  • apps/meteor/server/services/video-conference/service.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/server/services/video-conference/service.ts
🧠 Learnings (2)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/services/video-conference/service.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/services/video-conference/service.ts
🔇 Additional comments (2)
apps/meteor/server/services/video-conference/service.ts (2)

403-413: Good parallelization of independent count queries.

This is a clean latency improvement and aligns with the issue objective without changing behavior.


416-427: Return mapping looks correct after the refactor.

The stats fields are wired to the corresponding parallelized results with no observable API change.


Walkthrough

Refactored getStatistics() in the video conference service to run seven independent count queries concurrently via a single Promise.all(), consolidating awaits while preserving the method signature and return structure.

Changes

Cohort / File(s) Summary
Video Conference Statistics Optimization
apps/meteor/server/services/video-conference/service.ts
Replaced sequential await calls to VideoConferenceModel.countByTypeAndStatus() with a single Promise.all() to execute all seven independent count queries in parallel; returned fields now use the parallel results array.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant VideoConferenceService as Service
    participant VideoConferenceModel as Model
    participant Database

    Caller->>Service: getStatistics()
    Service->>Model: initiate 7 countByTypeAndStatus(...) calls
    par Parallel counts
        Model->>Database: count(query 1)
        Model->>Database: count(query 2)
        Model->>Database: count(query 3)
        Model->>Database: count(query 4)
        Model->>Database: count(query 5)
        Model->>Database: count(query 6)
        Model->>Database: count(query 7)
    end
    Database-->>Model: return counts (all)
    Model-->>Service: aggregated counts array
    Service-->>Caller: statistics object (mapped counts)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: refactoring the VideoConference service to execute statistics count queries in parallel using Promise.all instead of sequentially.
Linked Issues check ✅ Passed The PR successfully implements the objective from #39247 by wrapping seven independent countByTypeAndStatus calls in a single Promise.all() to execute concurrently, reducing total latency while maintaining identical behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to parallelizing the database queries in getStatistics() as specified in #39247; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-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.

No issues found across 1 file

@KevLehman KevLehman added the valid A valid contribution where maintainers will review based on priority label Mar 2, 2026
@Khizarshah01 Khizarshah01 force-pushed the refactor/parallelize-video-conference-statistics branch from cc135ad to a141a00 Compare March 2, 2026 16:18
@coderabbitai coderabbitai bot removed the type: chore label Mar 2, 2026
@KevLehman KevLehman added this to the 8.3.0 milestone Mar 2, 2026
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Mar 2, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Mar 2, 2026
@dionisio-bot dionisio-bot bot enabled auto-merge March 2, 2026 17:00
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.73%. Comparing base (a4341ec) to head (a141a00).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39248      +/-   ##
===========================================
+ Coverage    70.71%   70.73%   +0.02%     
===========================================
  Files         3195     3195              
  Lines       113108   113108              
  Branches     20526    20485      -41     
===========================================
+ Hits         79979    80004      +25     
+ Misses       31082    31059      -23     
+ Partials      2047     2045       -2     
Flag Coverage Δ
unit 71.36% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge valid A valid contribution where maintainers will review based on priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Video Conference statistics queries run sequentially instead of in parallel

2 participants