Skip to content
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

Merged
merged 12 commits into from
Mar 19, 2020

Conversation

MarcosSpessatto
Copy link
Member

No description provided.

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,
Copy link
Contributor

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.

@renatobecker renatobecker changed the title [IMPROVE] Livechat aggregations performance improvements [IMPROVE] Omnichannel aggregations performance improvements Mar 14, 2020
@renatobecker
Copy link
Contributor

@MarcosSpessatto please, review the 2 commits I submitted.
Thanks.

@renatobecker
Copy link
Contributor

The code looks good.
I can't merge it anymore because I submitted 2 commits, so I'll ask to @sampaiodiego to do it.

# Conflicts:
#	app/livechat/server/lib/Livechat.js
#	app/models/server/models/LivechatRooms.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants