Skip to content

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Dec 19, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Restored missing contact information in older call history entries. Previously incomplete call records now display the contact names and usernames that should have been present.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 19, 2025

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 Dec 19, 2025

⚠️ No Changeset found

Latest commit: c8ae694

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

@pierre-lehnen-rc pierre-lehnen-rc added this to the 8.0.0 milestone Dec 19, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

This PR introduces a new database migration (v332) that backfills missing contactName and contactUsername fields in older CallHistory entries by performing a MongoDB aggregation lookup against the Users collection and merging the results back into matching documents.

Changes

Cohort / File(s) Summary
Migration index
apps/meteor/server/startup/migrations/index.ts
Added import statement to register the new v332 migration module
Call history contact backfill migration
apps/meteor/server/startup/migrations/v332.ts
New migration that aggregates CallHistory documents where external is false and contactName/contactUsername are missing, looks up user details from the Users collection via contactId, and merges the resolved contact fields back into the collection

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify the aggregation pipeline logic, particularly the filtering conditions (external: false, contactId exists, missing contact fields)
  • Confirm the $lookup stage correctly joins with the Users collection and that field projection captures required fields
  • Note that aggregation result iteration appears to be a no-op; consider whether execution is guaranteed to complete

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ricardogarim
  • tassoevan

Poem

🐰 A migration hops through CallHistory's past,
Filling contact names, memories unsurpassed,
Aggregation pipelines dance with glee,
Legacy records—now complete and free! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: a migration that populates user names (contactName and contactUsername) into existing Call History entries for legacy records.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/call-history-name-migration

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.

@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review December 19, 2025 19:24
@pierre-lehnen-rc pierre-lehnen-rc requested a review from a team as a code owner December 19, 2025 19:24
@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Dec 19, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d14079a and 4699eb7.

📒 Files selected for processing (2)
  • apps/meteor/server/startup/migrations/index.ts (1 hunks)
  • apps/meteor/server/startup/migrations/v332.ts (1 hunks)
🧰 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/startup/migrations/v332.ts
  • apps/meteor/server/startup/migrations/index.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:23.819Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.
📚 Learning: 2025-12-18T15:18:23.819Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:23.819Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.

Applied to files:

  • apps/meteor/server/startup/migrations/v332.ts
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • apps/meteor/server/startup/migrations/v332.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/server/startup/migrations/index.ts
🧬 Code graph analysis (1)
apps/meteor/server/startup/migrations/v332.ts (1)
packages/models/src/index.ts (1)
  • CallHistory (141-141)
🔇 Additional comments (2)
apps/meteor/server/startup/migrations/v332.ts (1)

19-51: Aggregation pipeline logic looks correct.

The $lookup, $addFields, $project, and $merge stages are correctly structured. The for-await loop to drain the cursor is the correct pattern to ensure the $merge operation completes.

apps/meteor/server/startup/migrations/index.ts (1)

40-40: LGTM!

The new migration import follows the established pattern and is correctly sequenced after v331.

Comment on lines +11 to +16
$match: {
external: false,
contactId: { $exists: true },
contactName: { $exists: false },
contactUssername: { $exists: false },
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical typo: contactUssername should be contactUsername.

Line 15 has a typo with double 's' in contactUssername. This breaks the filter logic—documents that already have contactUsername populated will still match because contactUssername (the typo) doesn't exist on any document. This will cause the migration to unnecessarily process and update records that should be skipped.

🔎 Proposed fix
 			{
 				$match: {
 					external: false,
 					contactId: { $exists: true },
 					contactName: { $exists: false },
-					contactUssername: { $exists: false },
+					contactUsername: { $exists: false },
 				},
 			},
🤖 Prompt for AI Agents
In apps/meteor/server/startup/migrations/v332.ts around lines 11 to 16, the
$match filter contains a typo "contactUssername" (double 's') which prevents
correct filtering; change that key to "contactUsername" so the query checks the
actual field, update any other occurrences of the misspelled field in this file,
and run the migration/dry-run to verify only documents missing contactUsername
are processed.

@github-actions
Copy link
Contributor

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +7.2MiB
rocketchat 355MiB 347MiB +7.9MiB
omnichannel-transcript-service 132MiB 132MiB -158KiB
queue-worker-service 132MiB 132MiB -160KiB
ddp-streamer-service 126MiB 126MiB -103KiB
account-service 113MiB 113MiB -104KiB
authorization-service 111MiB 111MiB -98KiB
presence-service 110MiB 111MiB -96KiB

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 19:04", "12/19 19:54 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
Loading

Statistics (last 25 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.1GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37898
  • Baseline: develop
  • Timestamp: 2025-12-19 19:54:49 UTC
  • Historical data points: 25

Updated: Fri, 19 Dec 2025 19:54:50 GMT

@ggazzo ggazzo changed the title chore: migrate user names into existing Call History entries chore!: migrate user names into existing Call History entries Dec 19, 2025
@ggazzo ggazzo requested review from a team as code owners December 19, 2025 20:20
@ggazzo ggazzo force-pushed the chore/call-history-name-migration branch from 4699eb7 to c8ae694 Compare December 19, 2025 20:21
@ggazzo ggazzo merged commit 2a902d2 into release-8.0.0 Dec 19, 2025
6 of 8 checks passed
@ggazzo ggazzo deleted the chore/call-history-name-migration branch December 19, 2025 20:26
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants