Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Feb 24, 2025

Proposed changes (including videos or screenshots)

Idea is to stop using .col in models/app code and use just the methods exposed by the Base model.

This removes the usage of .col.countDocuments and .col.estimatedDocumentCount in favor of the methods defined in Base model.

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-456

Steps to test or reproduce

Further comments

I couldn't resist to remove 3 unnecesary awaits from the statistics, + change 3 countDocuments({}) to an estimatedDocumentCount, which should provide the same result (apart from some really bad circumstances)

From those 3, the Users one is the only "important", so feel free to comment if you think it has to continue to iterate the whole collection or we can live with the estimate

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2025

⚠️ No Changeset found

Latest commit: e132bc9

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 24, 2025

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

@codecov
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 59.44%. Comparing base (5457e94) to head (e132bc9).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #35319   +/-   ##
========================================
  Coverage    59.44%   59.44%           
========================================
  Files         2829     2829           
  Lines        68324    68324           
  Branches     15130    15130           
========================================
  Hits         40612    40612           
  Misses       25054    25054           
  Partials      2658     2658           
Flag Coverage Δ
unit 75.53% <0.00%> (ø)

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

@KevLehman KevLehman marked this pull request as ready for review February 24, 2025 15:47
@KevLehman KevLehman requested review from a team as code owners February 24, 2025 15:47
Copy link
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

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

I don't bother too much using this.col inside models, I think it could be just protected instead of public.. but that's fine..

as a first step I think we're good.. but I still would like to that we don't use countDocuments providing queries all over the place, I think we should be doing that inside models only.. I don't think this is making it worse though.

@KevLehman
Copy link
Member Author

Yeah, moving the count queries to their models would be nice. They're a lot and that would require a lot of changes, so i'll create a task for start moving those (and other queries that are outside them).

Thx man!

@KevLehman KevLehman added this to the 7.5.0 milestone Feb 25, 2025
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Feb 25, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 25, 2025
@kodiakhq kodiakhq bot merged commit 683df29 into develop Feb 25, 2025
47 of 48 checks passed
@kodiakhq kodiakhq bot deleted the refactor/private-col branch February 25, 2025 15:48
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.

4 participants