[IMPROVE] Omnichannel aggregations performance improvements#16755
[IMPROVE] Omnichannel aggregations performance improvements#16755sampaiodiego merged 12 commits intodevelopfrom
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.
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.