-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
[IMPROVE] Omnichannel aggregations performance improvements #16755
Conversation
agents: await Users.findAllAverageServiceTime({ start, end, options }), | ||
total: (await Users.findAllAverageServiceTime({ start, end })).length, | ||
agents: await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end, options }), | ||
total: (await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end })).length, |
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.
My suggestion is to change the way we get the total number of records without pagination, I mean, we don't need to get all data from the DB just to know the count/total
number, actually, we are wasting computational resources since we're allocation all documents in memory just to get the length
value.
IMO, we can use a native MongoDB
feature that returns exactly the value we need. To achieve this we need to support an additional function parameter, allowing to set something like onlyCount
parameter, also we'd need to return the cursor
instead of array
.
@MarcosSpessatto please, review the 2 commits I submitted. |
The code looks good. |
# Conflicts: # app/livechat/server/lib/Livechat.js # app/models/server/models/LivechatRooms.js
No description provided.