fix: engagement dashboard fill#41207
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📜 Recent review details⏰ Context from checks skipped due to timeout. (3)
|
| Layer / File(s) | Summary |
|---|---|
Analytics lookup contract and implementation packages/model-typings/src/models/IAnalyticsModel.ts, packages/models/src/models/Analytics.ts |
Replaces the cursor-based analytics lookup with findOneByTypeBeforeDate, returning a nullable matching record. |
Dashboard lookup integration and release metadata apps/meteor/ee/server/lib/engagementDashboard/messages.ts, apps/meteor/ee/server/lib/engagementDashboard/users.ts, .changeset/empty-boxes-cross.md |
Uses single-record existence checks when deciding whether to backfill message and user analytics, and records a patch release. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested labels: type: bug
🚥 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 clearly matches the main change: fixing the engagement dashboard fill behavior. |
| 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. |
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- SUP-1074: Request failed with status code 401
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.
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41207 +/- ##
===========================================
+ Coverage 68.98% 68.99% +0.01%
===========================================
Files 3757 3757
Lines 147735 147735
Branches 26381 26361 -20
===========================================
+ Hits 101919 101937 +18
+ Misses 41317 41298 -19
- Partials 4499 4500 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
69f3ae7 to
d3d4611
Compare
🦋 Changeset detectedLatest commit: b2af1ad The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/models/src/models/Analytics.ts (1)
219-221: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider adding
limit: 1since the sole consumer uses this as an existence check.The only caller (
fillFirstDaysOfMessagesIfNeeded) treats the result as a boolean (!messagesFromAnalytics), so MongoDB can short-circuit after finding one document. SincecountByTypeBeforeDatedoesn't accept options, you could either add an optionallimitparameter or create a dedicatedexistsByTypeBeforeDatemethod returningPromise<boolean>usingfindOnewith{ limit: 1 }.♻️ Option: add optional limit to the interface and implementation
// IAnalyticsModel.ts -countByTypeBeforeDate({ type, date }: { type: IAnalytics['type']; date: IAnalytics['date'] }): Promise<number>; +countByTypeBeforeDate({ type, date, limit }: { type: IAnalytics['type']; date: IAnalytics['date']; limit?: number }): Promise<number>;// Analytics.ts -countByTypeBeforeDate({ type, date }: { type: IAnalytics['type']; date: IAnalytics['date'] }): Promise<number> { - return this.countDocuments({ type, date: { $lte: date } }); +countByTypeBeforeDate({ type, date, limit }: { type: IAnalytics['type']; date: IAnalytics['date']; limit?: number }): Promise<number> { + return this.countDocuments({ type, date: { $lte: date } }, { limit }); }// messages.ts consumer const messagesFromAnalytics = await Analytics.countByTypeBeforeDate({ type: 'messages', date: convertDateToInt(date), + limit: 1, });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/models/src/models/Analytics.ts` around lines 219 - 221, Optimize the existence check used by fillFirstDaysOfMessagesIfNeeded: update countByTypeBeforeDate (and its interface) to support an optional limit, then pass limit: 1 from the caller, or add an existsByTypeBeforeDate method using findOne with limit: 1 and update the caller to use it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/models/src/models/Analytics.ts`:
- Around line 219-221: Optimize the existence check used by
fillFirstDaysOfMessagesIfNeeded: update countByTypeBeforeDate (and its
interface) to support an optional limit, then pass limit: 1 from the caller, or
add an existsByTypeBeforeDate method using findOne with limit: 1 and update the
caller to use it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c358d3b0-073e-4dda-afc1-ce902a961857
📒 Files selected for processing (4)
.changeset/empty-boxes-cross.mdapps/meteor/ee/server/lib/engagementDashboard/messages.tspackages/model-typings/src/models/IAnalyticsModel.tspackages/models/src/models/Analytics.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
- GitHub Check: CodeRabbit / Review
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
- GitHub Check: ⚙️ Variables Setup
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (1)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 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:
packages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.tsapps/meteor/ee/server/lib/engagementDashboard/messages.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/empty-boxes-cross.md
📚 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:
packages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.tsapps/meteor/ee/server/lib/engagementDashboard/messages.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:
packages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.tsapps/meteor/ee/server/lib/engagementDashboard/messages.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
packages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.tsapps/meteor/ee/server/lib/engagementDashboard/messages.ts
🔇 Additional comments (4)
packages/model-typings/src/models/IAnalyticsModel.ts (1)
42-42: LGTM!packages/models/src/models/Analytics.ts (1)
219-221: LGTM!apps/meteor/ee/server/lib/engagementDashboard/messages.ts (1)
37-41: LGTM!.changeset/empty-boxes-cross.md (1)
1-5: LGTM!
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".changeset/empty-boxes-cross.md">
<violation number="1" location=".changeset/empty-boxes-cross.md:5">
P1: The changeset describes a fix and requests a patch version bump, but no code changes implementing the fix are included. Merging this would generate a changelog entry and trigger a release with no actual changes, misleading consumers. Either revert the changeset or include the corresponding code changes.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
d3d4611 to
72addd0
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/models/src/models/Analytics.ts (1)
215-216: 🚀 Performance & Scalability | 🔵 TrivialConsider adding a compound index
{ type: 1, date: 1 }for this query.The
findOnequery{ type, date: { $lte: date } }can only use the existing{ date: 1 }index for the range scan, then filters bytypein memory. A compound index on{ type: 1, date: 1 }would let MongoDB seek directly to the right type prefix and scan dates, making this existence check even faster — especially relevant since this runs during dashboard startup viaprepareAnalytics.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/models/src/models/Analytics.ts` around lines 215 - 216, Add a compound MongoDB index on { type: 1, date: 1 } in the Analytics model/schema used by findOneByTypeBeforeDate, while preserving existing indexes unless they are redundant. Verify the index is registered during model initialization so prepareAnalytics queries can use it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/models/src/models/Analytics.ts`:
- Around line 215-216: Add a compound MongoDB index on { type: 1, date: 1 } in
the Analytics model/schema used by findOneByTypeBeforeDate, while preserving
existing indexes unless they are redundant. Verify the index is registered
during model initialization so prepareAnalytics queries can use it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a995cff5-0abf-47c2-94db-110d79edb381
📒 Files selected for processing (4)
apps/meteor/ee/server/lib/engagementDashboard/messages.tsapps/meteor/ee/server/lib/engagementDashboard/users.tspackages/model-typings/src/models/IAnalyticsModel.tspackages/models/src/models/Analytics.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: CodeRabbit / Review
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (4)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ❌ **Has milestone or project** — This PR is missing the required milestone or project
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 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/ee/server/lib/engagementDashboard/users.tsapps/meteor/ee/server/lib/engagementDashboard/messages.tspackages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.ts
🧠 Learnings (3)
📚 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/ee/server/lib/engagementDashboard/users.tsapps/meteor/ee/server/lib/engagementDashboard/messages.tspackages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.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/ee/server/lib/engagementDashboard/users.tsapps/meteor/ee/server/lib/engagementDashboard/messages.tspackages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
apps/meteor/ee/server/lib/engagementDashboard/users.tsapps/meteor/ee/server/lib/engagementDashboard/messages.tspackages/models/src/models/Analytics.tspackages/model-typings/src/models/IAnalyticsModel.ts
🔇 Additional comments (5)
packages/model-typings/src/models/IAnalyticsModel.ts (1)
41-41: LGTM!packages/models/src/models/Analytics.ts (2)
215-216: LGTM!
215-216: 🩺 Stability & AvailabilityNo action needed
apps/meteor/ee/server/lib/engagementDashboard/messages.ts (1)
37-41: LGTM!apps/meteor/ee/server/lib/engagementDashboard/users.ts (1)
20-24: LGTM!
99263f0 to
b2af1ad
Compare
Proposed changes (including videos or screenshots)
Issue(s)
SUP-1074
Steps to test or reproduce
Further comments
Summary by CodeRabbit