diff --git a/app/models/server/models/Messages.js b/app/models/server/models/Messages.js index 48b785bfc674..6f061486c5f2 100644 --- a/app/models/server/models/Messages.js +++ b/app/models/server/models/Messages.js @@ -998,6 +998,10 @@ export class Messages extends Base { // ////////////////////////////////////////////////////////////////// // threads + countThreads() { + return this.find({ tcount: { $exists: true } }).count(); + } + removeThreadRefByThreadId(tmid) { const query = { tmid }; const update = { diff --git a/app/models/server/models/Rooms.js b/app/models/server/models/Rooms.js index a64dcb78c401..747023f16cbe 100644 --- a/app/models/server/models/Rooms.js +++ b/app/models/server/models/Rooms.js @@ -10,17 +10,17 @@ export class Rooms extends Base { constructor(...args) { super(...args); - this.tryEnsureIndex({ name: 1 }, { unique: 1, sparse: 1 }); + this.tryEnsureIndex({ name: 1 }, { unique: true, sparse: true }); this.tryEnsureIndex({ default: 1 }); this.tryEnsureIndex({ t: 1 }); this.tryEnsureIndex({ 'u._id': 1 }); this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 }); - this.tryEnsureIndex({ open: 1 }, { sparse: 1 }); - this.tryEnsureIndex({ departmentId: 1 }, { sparse: 1 }); + this.tryEnsureIndex({ open: 1 }, { sparse: true }); + this.tryEnsureIndex({ departmentId: 1 }, { sparse: true }); this.tryEnsureIndex({ ts: 1 }); // discussions - this.tryEnsureIndex({ prid: 1 }); + this.tryEnsureIndex({ prid: 1 }, { sparse: true }); } findOneByIdOrName(_idOrName, options) { @@ -1413,6 +1413,10 @@ export class Rooms extends Base { return this.update(query, update); } + + countDiscussions() { + return this.find({ prid: { $exists: true } }).count(); + } } export default new Rooms('room', true); diff --git a/app/statistics/server/functions/get.js b/app/statistics/server/functions/get.js index 8e090f9b2884..0224bb002824 100644 --- a/app/statistics/server/functions/get.js +++ b/app/statistics/server/functions/get.js @@ -1,12 +1,24 @@ -import { Meteor } from 'meteor/meteor'; -import { MongoInternals } from 'meteor/mongo'; import _ from 'underscore'; import os from 'os'; + +import { Meteor } from 'meteor/meteor'; +import { MongoInternals } from 'meteor/mongo'; import { InstanceStatus } from 'meteor/konecty:multiple-instances-status'; -import { Sessions, Settings, Users, Rooms, Subscriptions, Uploads, Messages, LivechatVisitors } from '../../../models'; -import { settings } from '../../../settings'; -import { Info } from '../../../utils'; -import { Migrations } from '../../../migrations'; + +import { + Sessions, + Settings, + Users, + Rooms, + Subscriptions, + Uploads, + Messages, + LivechatVisitors, +} from '../../../models/server'; +import { settings } from '../../../settings/server'; +import { Info } from '../../../utils/server'; +import { Migrations } from '../../../migrations/server'; + import { statistics } from '../statisticsNamespace'; const wizardFields = [ @@ -62,6 +74,7 @@ statistics.get = function _getStatistics() { statistics.nonActiveUsers = statistics.totalUsers - statistics.activeUsers; statistics.onlineUsers = Meteor.users.find({ statusConnection: 'online' }).count(); statistics.awayUsers = Meteor.users.find({ statusConnection: 'away' }).count(); + statistics.totalConnectedUsers = statistics.onlineUsers + statistics.awayUsers; statistics.offlineUsers = statistics.totalUsers - statistics.onlineUsers - statistics.awayUsers; // Room statistics @@ -70,6 +83,8 @@ statistics.get = function _getStatistics() { statistics.totalPrivateGroups = Rooms.findByType('p').count(); statistics.totalDirect = Rooms.findByType('d').count(); statistics.totalLivechat = Rooms.findByType('l').count(); + statistics.totalDiscussions = Rooms.countDiscussions(); + statistics.totalThreads = Messages.countThreads(); // livechat visitors statistics.totalLivechatVisitors = LivechatVisitors.find().count(); @@ -128,10 +143,11 @@ statistics.get = function _getStatistics() { } try { - const { version } = Promise.await(mongo.db.command({ buildInfo: 1 })); + const { version, storageEngine } = Promise.await(mongo.db.command({ serverStatus: 1 })); statistics.mongoVersion = version; + statistics.mongoStorageEngine = storageEngine.name; } catch (e) { - console.error('Error getting MongoDB version'); + console.error('Error getting MongoDB info'); } statistics.uniqueUsersOfYesterday = Sessions.getUniqueUsersOfYesterday(); diff --git a/app/ui-admin/client/adminInfo.html b/app/ui-admin/client/adminInfo.html index f4ec83d3f3cd..7e9b701fea31 100644 --- a/app/ui-admin/client/adminInfo.html +++ b/app/ui-admin/client/adminInfo.html @@ -112,6 +112,15 @@

{{_ "Runtime_Environment"}}

{{_ "Node_version"}} {{statistics.process.nodeVersion}} + + {{_ "Mongo_version"}} + {{statistics.mongoVersion}} + + + {{_ "Mongo_storageEngine"}} + {{statistics.mongoStorageEngine}} + + {{_ "OS_Uptime"}} {{humanReadableTime statistics.os.uptime}} @@ -173,6 +182,10 @@

{{_ "Usage"}}

{{_ "Stats_Non_Active_Users"}} {{statistics.nonActiveUsers}} + + {{_ "Stats_Total_Connected_Users"}} + {{statistics.totalConnectedUsers}} + {{_ "Stats_Online_Users"}} {{statistics.onlineUsers}} @@ -205,6 +218,14 @@

{{_ "Usage"}}

{{_ "Stats_Total_Livechat_Rooms"}} {{statistics.totalLivechat}} + + {{_ "Total_Discussions"}} + {{statistics.totalDiscussions}} + + + {{_ "Total_Threads"}} + {{statistics.totalThreads}} + {{_ "Stats_Total_Messages"}} {{statistics.totalMessages}} diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index f720435465f2..c0fab1146b97 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2032,6 +2032,8 @@ "Mobile": "Mobile", "Mobile_Notifications_Default_Alert": "Mobile Notifications Default Alert", "Monday": "Monday", + "Mongo_version": "Mongo Version", + "Mongo_storageEngine": "Mongo Storage Engine", "Monitor_history_for_changes_on": "Monitor History for Changes on", "More": "More", "More_channels": "More channels", @@ -2687,14 +2689,15 @@ "Statistics": "Statistics", "Statistics_reporting": "Send Statistics to Rocket.Chat", "Statistics_reporting_Description": "By sending your statistics, you'll help us identify how many instances of Rocket.Chat are deployed, as well as how good the system is behaving, so we can further improve it. Don't worry, as no user information is sent and all the information we receive is kept confidential.", - "Stats_Active_Users": "Active Users", + "Stats_Active_Users": "Activated Users", "Stats_Avg_Channel_Users": "Average Channel Users", "Stats_Avg_Private_Group_Users": "Average Private Group Users", "Stats_Away_Users": "Away Users", "Stats_Max_Room_Users": "Max Rooms Users", - "Stats_Non_Active_Users": "Inactive Users", + "Stats_Non_Active_Users": "Deactivated Users", "Stats_Offline_Users": "Offline Users", "Stats_Online_Users": "Online Users", + "Stats_Total_Connected_Users": "Total Connected Users", "Stats_Total_Channels": "Total Channels", "Stats_Total_Direct_Messages": "Total Direct Message Rooms", "Stats_Total_Livechat_Rooms": "Total Livechat Rooms", @@ -2863,7 +2866,9 @@ "Topic": "Topic", "Total": "Total", "Total_conversations": "Total Conversations", + "Total_Discussions": "Total Discussions", "Total_messages": "Total Messages", + "Total_Threads": "Total Threads", "Total_visitors": "Total Visitors", "Tourism": "Tourism", "Transcript_Enabled": "Ask Visitor if They Would Like a Transcript After Chat Closed", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 125491c0a21c..05c070b67366 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -2841,7 +2841,9 @@ "Topic": "Tópico", "Total": "Total", "Total_conversations": "Total de conversas", + "Total_Discussions": "Total de discussões", "Total_messages": "Quantidade de Mensagens", + "Total_Threads": "Total de tópicos", "Total_visitors": "Total de visitantes", "Tourism": "Turismo", "Transcript_Enabled": "Pergunte ao visitante se eles gostariam de uma transcrição após o bate-papo fechado", diff --git a/server/startup/serverRunning.js b/server/startup/serverRunning.js index 4d097f51e78e..a7859d005a28 100644 --- a/server/startup/serverRunning.js +++ b/server/startup/serverRunning.js @@ -20,9 +20,11 @@ Meteor.startup(function() { } let mongoDbVersion; + let mongoDbEngine; try { - const { version } = Promise.await(mongo.db.command({ buildInfo: 1 })); + const { version, storageEngine } = Promise.await(mongo.db.command({ serverStatus: 1 })); mongoDbVersion = version; + mongoDbEngine = storageEngine.name; } catch (e) { mongoDbVersion = 'Error getting version'; console.error('Error getting MongoDB version'); @@ -36,6 +38,7 @@ Meteor.startup(function() { `Rocket.Chat Version: ${ Info.version }`, ` NodeJS Version: ${ process.versions.node } - ${ process.arch }`, ` MongoDB Version: ${ mongoDbVersion }`, + ` MongoDB Engine: ${ mongoDbEngine }`, ` Platform: ${ process.platform }`, ` Process Port: ${ process.env.PORT }`, ` Site URL: ${ settings.get('Site_Url') }`,