Skip to content

Commit

Permalink
Troubleshoot_Disable_Statistics_Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Sep 18, 2023
1 parent b1c2a4c commit 20bd445
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
2 changes: 0 additions & 2 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5174,8 +5174,6 @@
"Troubleshoot_Disable_Presence_Broadcast_Alert": "This setting prevents all instances form sending the status changes of the users to their clients keeping all the users with their presence status from the first load!",
"Troubleshoot_Disable_Sessions_Monitor": "Disable Sessions Monitor",
"Troubleshoot_Disable_Sessions_Monitor_Alert": "This setting stops the processing of user sessions causing the statistics to stop working correctly!",
"Troubleshoot_Disable_Statistics_Generator": "Disable Statistics Generator",
"Troubleshoot_Disable_Statistics_Generator_Alert": "This setting stops the processing all statistics making the info page outdated until someone clicks on the refresh button and may cause other missing information around the system!",
"Troubleshoot_Disable_Workspace_Sync": "Disable Workspace Sync",
"Troubleshoot_Disable_Workspace_Sync_Alert": "This setting stops the sync of this server with Rocket.Chat's cloud and may cause issues with marketplace and enteprise licenses!",
"Troubleshoot_Disable_Teams_Mention": "Disable Teams mention",
Expand Down
24 changes: 3 additions & 21 deletions apps/meteor/server/cron/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,10 @@ async function generateStatistics(logger: Logger): Promise<void> {
}

export async function statsCron(logger: Logger): Promise<void> {
if (settings.get('Troubleshoot_Disable_Statistics_Generator')) {
return;
}

const name = 'Generate and save statistics';
await generateStatistics(logger);

let previousValue: boolean;
settings.watch<boolean>('Troubleshoot_Disable_Statistics_Generator', async (value) => {
if (value === previousValue) {
return;
}
previousValue = value;

if (value) {
await cronJobs.remove(name);
return;
}

await generateStatistics(logger);

const now = new Date();
const now = new Date();

await cronJobs.add(name, `12 ${now.getHours()} * * *`, async () => generateStatistics(logger));
});
await cronJobs.add(name, `12 ${now.getHours()} * * *`, async () => generateStatistics(logger));
}
15 changes: 6 additions & 9 deletions apps/meteor/server/settings/troubleshoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const createTroubleshootSettings = () =>
i18nDescription: 'Troubleshoot_Disable_Presence_Broadcast_Alert',
enableQuery: { _id: 'Presence_broadcast_disabled', value: false },
});

await this.add('Troubleshoot_Disable_Instance_Broadcast', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Instance_Broadcast_Alert',
Expand All @@ -32,18 +31,16 @@ export const createTroubleshootSettings = () =>
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Livechat_Activity_Monitor_Alert',
});
await this.add('Troubleshoot_Disable_Statistics_Generator', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Statistics_Generator_Alert',
});
await this.add('Troubleshoot_Disable_Data_Exporter_Processor', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Data_Exporter_Processor_Alert',
});
await this.add('Troubleshoot_Disable_Workspace_Sync', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Workspace_Sync_Alert',
});

// await this.add('Troubleshoot_Disable_Workspace_Sync', false, {
// type: 'boolean',
// i18nDescription: 'Troubleshoot_Disable_Workspace_Sync_Alert',
// });

await this.add('Troubleshoot_Disable_Teams_Mention', false, {
type: 'boolean',
i18nDescription: 'Troubleshoot_Disable_Teams_Mention_Alert',
Expand Down

0 comments on commit 20bd445

Please sign in to comment.