code review updates

Summary of what we fixed based on AI review feedback:

Formatting - Ran Prettier to fix code formatting
Redux state rollback - Moved Redux dispatch to after successful save in settingsHooks.js
Performance - Added caching layer in settingsModule (1-minute TTL) to prevent DB query on every status page request
Architecture - Inject settingsModule instead of raw AppSettings model for better encapsulation
This commit is contained in:
Craig Lawson committed 2026-01-11 20:51:25 +00:00
1 parent 7b619e6b31
commit 7556086f71
5 files changed
+47 -18

No files matched your search

+11 -11
View File
@@ -5,11 +5,11 @@
const SERVICE_NAME = "statusPageModule";
class StatusPageModule {
constructor({ StatusPage, NormalizeData, stringService, AppSettings }) {
constructor({ StatusPage, NormalizeData, stringService, settingsModule }) {
this.StatusPage = StatusPage;
this.NormalizeData = NormalizeData;
this.stringService = stringService;
this.AppSettings = AppSettings;
this.settingsModule = settingsModule;
}
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
@@ -260,19 +260,19 @@ class StatusPageModule {
const { statusPage, monitors } = statusPageQuery[0];
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
const appSettings = await this.settingsModule.getAppSettings();
const showURL = appSettings?.showURL === true;
const normalizedMonitors = monitors.map((monitor) => {
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
if (showURL !== true) {
const { url, port, secret, notifications, ...rest } = monitor;
return { ...rest, checks: normalizedChecks };
}
return { ...monitor, checks: normalizedChecks };
});
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
if (showURL !== true) {
const { url, port, secret, notifications, ...rest } = monitor;
return { ...rest, checks: normalizedChecks };
}
return { ...monitor, checks: normalizedChecks };
});
return { statusPage, monitors: normalizedMonitors };
return { statusPage, monitors: normalizedMonitors };
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getStatusPageByUrl";