Skip to content

chore: avoid fetching data just for counting#41313

Merged
ggazzo merged 2 commits into
developfrom
chore-avoid-fetching-data-for-counts
Jul 17, 2026
Merged

chore: avoid fetching data just for counting#41313
ggazzo merged 2 commits into
developfrom
chore-avoid-fetching-data-for-counts

Conversation

@sampaiodiego

@sampaiodiego sampaiodiego commented Jul 10, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Issue(s)

Follow up of #41207

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Performance Improvements
    • Improved response times and resource usage for message delivery, permission updates, custom sounds, custom emoji, user statuses, and live chat room lookups.
    • Reduced unnecessary data retrieval during SAML logout processing and message cleanup.
  • Statistics
    • Improved integration statistics processing while preserving existing reporting results.
  • Reliability
    • Strengthened validation for referenced permissions and roles, with clearer handling of invalid entries.
      SUP-1074

@dionisio-bot

dionisio-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9e546a8

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

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


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.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.16%. Comparing base (b634242) to head (619b5a8).
⚠️ Report is 28 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41313      +/-   ##
===========================================
- Coverage    68.27%   68.16%   -0.11%     
===========================================
  Files         3968     3968              
  Lines       154740   154725      -15     
  Branches     27847    27818      -29     
===========================================
- Hits        105652   105476     -176     
- Misses       44294    44452     +158     
- Partials      4794     4797       +3     
Flag Coverage Δ
e2e 59.23% <ø> (-0.15%) ⬇️
e2e-api 44.00% <69.23%> (-0.37%) ⬇️
unit 70.58% <0.00%> (-0.09%) ⬇️

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.

@sampaiodiego
sampaiodiego force-pushed the chore-avoid-fetching-data-for-counts branch from 5eb8db5 to 4348969 Compare July 14, 2026 19:09
@sampaiodiego
sampaiodiego marked this pull request as ready for review July 14, 2026 20:16
@sampaiodiego
sampaiodiego requested review from a team as code owners July 14, 2026 20:16

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 19 files

Re-trigger cubic

KevLehman
KevLehman previously approved these changes Jul 14, 2026
@sampaiodiego sampaiodiego added this to the 8.7.0 milestone Jul 14, 2026
@sampaiodiego sampaiodiego added the stat: QA assured Means it has been tested and approved by a company insider label Jul 14, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 14, 2026
ggazzo
ggazzo previously approved these changes Jul 15, 2026
@dionisio-bot dionisio-bot Bot added stat: conflict and removed stat: ready to merge PR tested and approved waiting for merge labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The pull request replaces several full-result database queries with targeted lookups, bounded projections, count operations, and aggregation. It adds model interfaces and implementations for single-record lookups and integration statistics, then updates affected application flows.

Changes

Database Query Optimization

Layer / File(s) Summary
Single-record lookup APIs
packages/model-typings/src/models/ICustomSoundsModel.ts, packages/model-typings/src/models/ICustomUserStatusModel.ts, packages/model-typings/src/models/IEmojiCustomModel.ts, packages/model-typings/src/models/ILivechatRoomsModel.ts, packages/models/src/models/CustomSounds.ts, packages/models/src/models/CustomUserStatus.ts, packages/models/src/models/EmojiCustom.ts, packages/models/src/models/LivechatRooms.ts, apps/meteor/app/user-status/..., apps/meteor/server/lib/media/..., apps/meteor/server/api/v1/omnichannel/message.ts
Single-record model methods and projections replace materialized name, alias, status, and room lookups.
Count-based validation
packages/model-typings/src/models/IBaseModel.ts, apps/meteor/server/api/v1/permissions.ts, packages/models/src/models/Messages.ts
Permission, role, and message matching checks use countDocuments, including optional count options and preserved limits.
Bounded SAML lookups
apps/meteor/server/lib/saml/lib/SAML.ts
SAML logout lookups project _id and limit results to two while retaining missing, unique, and ambiguous result handling.
Aggregated integration statistics
packages/model-typings/src/models/IIntegrationsModel.ts, packages/models/src/models/Integrations.ts, apps/meteor/server/lib/statistics/lib/statistics.ts
A typed getStatistics aggregation computes integration totals and status counters for the statistics response.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: type: chore

Suggested reviewers: tassoevan, kevl ehman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing fetches with count/existence checks.

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.

@sampaiodiego
sampaiodiego dismissed stale reviews from ggazzo and KevLehman via 9e546a8 July 17, 2026 13:45
@sampaiodiego
sampaiodiego force-pushed the chore-avoid-fetching-data-for-counts branch from 619b5a8 to 9e546a8 Compare July 17, 2026 13:45
@sampaiodiego
sampaiodiego requested a review from a team as a code owner July 17, 2026 13:45
@ggazzo
ggazzo merged commit fce0bc7 into develop Jul 17, 2026
18 of 33 checks passed
@ggazzo
ggazzo deleted the chore-avoid-fetching-data-for-counts branch July 17, 2026 13:46

@hacktron-app hacktron-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 2 files

Severity Count
HIGH 1
MEDIUM 1

Findings outside your changes (2)

2 additional security findings were found outside your changes. Details are hidden on public repositories — review them in Hacktron: Finding 1 · Finding 2

View full scan results

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 type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants