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 @@