Skip to content

Commit

Permalink
Move startup to be EE wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Feb 13, 2023
1 parent 3e2d92c commit 9ee4a05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/federation/server/functions/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/business-hour/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const openBusinessHourDefault = async (): Promise<void> => {
};

export const createDefaultBusinessHourIfNotExists = async (): Promise<void> => {
if ((await LivechatBusinessHours.find({ type: LivechatBusinessHourTypes.DEFAULT }).count()) === 0) {
if ((await LivechatBusinessHours.col.countDocuments({ type: LivechatBusinessHourTypes.DEFAULT })) === 0) {
await LivechatBusinessHours.insertOne(createDefaultBusinessHourRow());
}
};
28 changes: 10 additions & 18 deletions apps/meteor/app/statistics/server/lib/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/app/livechat-enterprise/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -39,6 +38,7 @@ import './business-hour';
onLicense('livechat-enterprise', () => {
require('./api');
require('./hooks');
require('./startup');
const { createPermissions } = require('./permissions');
const { createSettings } = require('./settings');

Expand Down

0 comments on commit 9ee4a05

Please sign in to comment.