-
Notifications
You must be signed in to change notification settings - Fork 13k
refactor: Make Base.col fully private - 1
#35319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
Looks like this PR is ready to merge! 🎉 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this 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.
|
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! |
Proposed changes (including videos or screenshots)
Idea is to stop using
.colin models/app code and use just the methods exposed by the Base model.This removes the usage of
.col.countDocumentsand.col.estimatedDocumentCountin favor of the methods defined inBasemodel.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 anestimatedDocumentCount, which should provide the same result (apart from some really bad circumstances)From those 3, the
Usersone 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