diff --git a/apps/meteor/app/federation/server/functions/dashboard.js b/apps/meteor/app/federation/server/functions/dashboard.js index 149e2215f73f..c31bf091e642 100644 --- a/apps/meteor/app/federation/server/functions/dashboard.js +++ b/apps/meteor/app/federation/server/functions/dashboard.js @@ -6,7 +6,7 @@ import { FederationRoomEvents, Users } from '../../../models/server'; export async function getStatistics() { const numberOfEvents = FederationRoomEvents.find().count(); const numberOfFederatedUsers = Users.findRemote().count(); - const numberOfServers = await FederationServers.find().count(); + const numberOfServers = await FederationServers.col.estimatedDocumentCount(); return { numberOfEvents, numberOfFederatedUsers, numberOfServers }; } diff --git a/apps/meteor/app/livechat/server/business-hour/Helper.ts b/apps/meteor/app/livechat/server/business-hour/Helper.ts index 08c0a8e47c01..771533931f53 100644 --- a/apps/meteor/app/livechat/server/business-hour/Helper.ts +++ b/apps/meteor/app/livechat/server/business-hour/Helper.ts @@ -57,7 +57,7 @@ export const openBusinessHourDefault = async (): Promise => { }; export const createDefaultBusinessHourIfNotExists = async (): Promise => { - if ((await LivechatBusinessHours.find({ type: LivechatBusinessHourTypes.DEFAULT }).count()) === 0) { + if ((await LivechatBusinessHours.col.countDocuments({ type: LivechatBusinessHourTypes.DEFAULT })) === 0) { await LivechatBusinessHours.insertOne(createDefaultBusinessHourRow()); } }; diff --git a/apps/meteor/app/statistics/server/lib/statistics.ts b/apps/meteor/app/statistics/server/lib/statistics.ts index 96a02ab2524d..5f0aba1e3eff 100644 --- a/apps/meteor/app/statistics/server/lib/statistics.ts +++ b/apps/meteor/app/statistics/server/lib/statistics.ts @@ -120,7 +120,7 @@ export const statistics = { statistics.totalThreads = Messages.countThreads(); // livechat visitors - statistics.totalLivechatVisitors = await LivechatVisitors.find().count(); + statistics.totalLivechatVisitors = await LivechatVisitors.col.estimatedDocumentCount(); // livechat agents statistics.totalLivechatAgents = Users.findAgents().count(); @@ -207,12 +207,9 @@ export const statistics = { // Amount of VoIP Extensions connected statsPms.push( - UsersRaw.col - .find({ extension: { $exists: true } }) - .count() - .then((count) => { - statistics.voipExtensions = count; - }), + UsersRaw.col.countDocuments({ extension: { $exists: true } }).then((count) => { + statistics.voipExtensions = count; + }), ); // Amount of Calls that ended properly @@ -310,11 +307,9 @@ export const statistics = { statistics.enterpriseReady = true; statsPms.push( - Uploads.find() - .count() - .then((count) => { - statistics.uploadsTotal = count; - }), + Uploads.col.estimatedDocumentCount().then((count) => { + statistics.uploadsTotal = count; + }), ); statsPms.push( Uploads.col @@ -335,12 +330,9 @@ export const statistics = { statistics.migration = getControl(); statsPms.push( - InstanceStatus.col - .find({ _updatedAt: { $gt: new Date(Date.now() - process.uptime() * 1000 - 2000) } }) - .count() - .then((count) => { - statistics.instanceCount = count; - }), + InstanceStatus.col.countDocuments({ _updatedAt: { $gt: new Date(Date.now() - process.uptime() * 1000 - 2000) } }).then((count) => { + statistics.instanceCount = count; + }), ); const { oplogEnabled, mongoVersion, mongoStorageEngine } = getMongoInfo(); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/index.js b/apps/meteor/ee/app/livechat-enterprise/server/index.js index d40386b6287b..9a5759715612 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/index.js +++ b/apps/meteor/ee/app/livechat-enterprise/server/index.js @@ -15,7 +15,6 @@ import './methods/resumeOnHold'; import LivechatUnit from '../../models/server/models/LivechatUnit'; import LivechatTag from '../../models/server/models/LivechatTag'; import LivechatUnitMonitors from '../../models/server/models/LivechatUnitMonitors'; -import './startup'; import './hooks/afterTakeInquiry'; import './hooks/beforeNewInquiry'; import './hooks/beforeNewRoom'; @@ -39,6 +38,7 @@ import './business-hour'; onLicense('livechat-enterprise', () => { require('./api'); require('./hooks'); + require('./startup'); const { createPermissions } = require('./permissions'); const { createSettings } = require('./settings');