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

Message count in statistics is strange #10233

Closed
janrudolph opened this issue Mar 27, 2018 · 3 comments · Fixed by #16680
Closed

Message count in statistics is strange #10233

janrudolph opened this issue Mar 27, 2018 · 3 comments · Fixed by #16680

Comments

@janrudolph
Copy link

Description:

In the admin info panel Rocket.chat displays usage statistics. However, it seems that the message count is not correct.

Server Setup Information:

  • Version of Rocket.Chat Server: 0.61.1

Actual behavior:

usage-count

=> as you see, the sum of all message is not correct if

Total Messages = Total Messages in Channels + Total Messages in Private Groups + Total Messages in Direct Messages + Total Messages in Livechats

@kaiiiiiiiii
Copy link
Contributor

The total message count is different because the calculation of the values is based on two different tables. The best thing would be to sum up the four already calculated values to get the exact total message count. However, I am not sure if the message count stored in the room object is always up to date.

// Message statistics
statistics.totalMessages = RocketChat.models.Messages.find().count();
statistics.totalChannelMessages = _.reduce(RocketChat.models.Rooms.findByType('c', { fields: { 'msgs': 1 }}).fetch(), function _countChannelMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalPrivateGroupMessages = _.reduce(RocketChat.models.Rooms.findByType('p', { fields: { 'msgs': 1 }}).fetch(), function _countPrivateGroupMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalDirectMessages = _.reduce(RocketChat.models.Rooms.findByType('d', { fields: { 'msgs': 1 }}).fetch(), function _countDirectMessages(num, room) { return num + room.msgs; }, 0);
statistics.totalLivechatMessages = _.reduce(RocketChat.models.Rooms.findByType('l', { fields: { 'msgs': 1 }}).fetch(), function _countLivechatMessages(num, room) { return num + room.msgs; }, 0);

I'll submit a PR for that.

@engelgabriel
Copy link
Member

Ref: #10726

@theorenck theorenck modified the milestones: 0.65.0, Short-term Jul 31, 2018
@subham103
Copy link
Contributor

Previously, the message count for every channel is increased upon message addition but is not updated upon the deletion of a message #12610. Now that I have linked a pr #16650 on this issue we can save/fetch the actual message count of any channel onto/from the database.

So it will be better if we sum up the four values to get the exact total message count.

I want to work on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants