Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Oct 17, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

Release Notes

  • Refactor
    • Improved type flexibility for room data retrieval operations. This internal optimization enhances system reliability and maintainability without impacting user-facing functionality.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 17, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.12.0, but it targets 7.11.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2025

⚠️ No Changeset found

Latest commit: 917ac8a

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

@KevLehman KevLehman added this to the 7.12.0 milestone Oct 17, 2025
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Oct 17, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Oct 17, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Walkthrough

The findOneByIdAndType method is generified in both its interface definition and implementation, allowing callers to specify a concrete document type T instead of being constrained to IRoom. The method now returns Promise<T | null> with generic FindOptions<T> support.

Changes

Cohort / File(s) Summary
Type Definition
packages/model-typings/src/models/IRoomsModel.ts
Method signature updated to accept generic type parameter T extends Document = IRoom, with FindOptions and return type now parameterized as FindOptions<T> and Promise<T | null> respectively
Implementation
packages/models/src/models/Rooms.ts
Method implementation generified with <T extends Document = IRoom>, delegating to findOne<T>() and casting default options to FindOptions<T>

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

The changes are homogeneous and targeted—a single method is consistently generified across the interface and implementation with clear intent. Type constraint consistency and the options cast require brief verification.

Poem

🐰 A method once bound to a single type's call,
Now flexes with generics and answers them all!
With T extends Document, the bounds are now clear—
More types can be handled, both far and near!
hops excitedly 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The PR title states "Add projection to Rooms.findOneByIdAndType", but the actual changes in the pull request are focused on making the findOneByIdAndType method generic by adding a type parameter T extends Document. The method signature was updated from a concrete type returning Promise<IRoom | null> to a generic signature returning Promise<T | null>, allowing callers to specify a more specific document subtype. While this generic typing can enable better type safety for operations involving projections, the title is misleading because it suggests that projection functionality was directly added to the method, when the core change is about type parameterization and generics. The title does not accurately describe the primary technical change in the changeset. Consider updating the PR title to more accurately reflect the main change, such as "refactor: Make Rooms.findOneByIdAndType generic for type-safe querying" or "chore: Add generic type parameter to Rooms.findOneByIdAndType". This would better convey that the change is about generics and type safety rather than adding projection functionality to the method itself.
✅ Passed checks (2 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 changes. Docstring coverage check skipped.
✨ 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/add-projection-to-find-by

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.

@KevLehman KevLehman marked this pull request as ready for review October 17, 2025 15:35
@KevLehman KevLehman requested a review from a team as a code owner October 17, 2025 15:35
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: 0

🧹 Nitpick comments (1)
packages/models/src/models/Rooms.ts (1)

944-950: Remove unnecessary type-cast default; align implementation with interface signature.

The interface in packages/model-typings/src/models/IRoomsModel.ts:207 already declares options?: FindOptions<T> (optional). The implementation should match. The only call site at apps/meteor/app/otr/server/methods/updateOTRAck.ts:42 explicitly provides options, so making the parameter optional is safe and eliminates the unsafe cast.

Apply:

-	findOneByIdAndType<T extends Document = IRoom>(
-		roomId: IRoom['_id'],
-		type: IRoom['t'],
-		options: FindOptions<T> = {} as FindOptions<T>,
-	): Promise<T | null> {
-		return this.findOne<T>({ _id: roomId, t: type }, options);
-	}
+	findOneByIdAndType<T extends Document = IRoom>(
+		roomId: IRoom['_id'],
+		type: IRoom['t'],
+		options?: FindOptions<T>,
+	): Promise<T | null> {
+		return this.findOne<T>({ _id: roomId, t: type }, options);
+	}
📜 Review details

Configuration used: CodeRabbit 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 c253db3 and 917ac8a.

📒 Files selected for processing (2)
  • packages/model-typings/src/models/IRoomsModel.ts (1 hunks)
  • packages/models/src/models/Rooms.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/models/src/models/Rooms.ts (1)
packages/core-typings/src/IRoom.ts (1)
  • IRoom (21-95)
packages/model-typings/src/models/IRoomsModel.ts (1)
packages/core-typings/src/IRoom.ts (1)
  • IRoom (21-95)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: 📦 Build Packages
🔇 Additional comments (1)
packages/model-typings/src/models/IRoomsModel.ts (1)

207-207: Signature verified and correctly implemented.

The interface and implementation signatures match exactly. The generic T extends Document = IRoom is correctly propagated through to the internal findOne<T>() call, and the call site at apps/meteor/app/otr/server/methods/updateOTRAck.ts:42 compiles without errors. The pattern aligns with MongoDB driver conventions for typed projections.

Optional enhancements:

  • Add JSDoc for T to clarify it represents the projected document shape.
  • Consider applying this generic pattern to other similar findOne* methods for consistency (currently, findOneByIdAndType is the only generic method in the interface).

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.63%. Comparing base (c253db3) to head (917ac8a).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37254      +/-   ##
===========================================
- Coverage    67.64%   67.63%   -0.02%     
===========================================
  Files         3341     3341              
  Lines       114016   114016              
  Branches     20671    20672       +1     
===========================================
- Hits         77131    77116      -15     
- Misses       34207    34224      +17     
+ Partials      2678     2676       -2     
Flag Coverage Δ
e2e 57.34% <ø> (+0.01%) ⬆️
unit 71.60% <ø> (-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.

@kodiakhq kodiakhq bot merged commit 7997811 into develop Oct 17, 2025
52 checks passed
@kodiakhq kodiakhq bot deleted the chore/add-projection-to-find-by branch October 17, 2025 16:31
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