mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-19 16:08:39 -05:00
Revert caching changes - restore working implementation
- Remove settingsModule caching that caused inconsistent state - Restore direct AppSettings query in statusPageModule - Keep immediate Redux dispatch for UI feedback - All functionality verified working"
This commit is contained in:
@@ -83,8 +83,7 @@ export const initializeServices = async ({ logger, envSettings, settingsService
|
||||
// Create DB
|
||||
const checkModule = new CheckModule({ logger, Check, Monitor, User });
|
||||
const inviteModule = new InviteModule({ InviteToken, crypto, stringService });
|
||||
const settingsModule = new SettingsModule({ AppSettings });
|
||||
const statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService, settingsModule });
|
||||
const statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService, AppSettings });
|
||||
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
|
||||
const maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
|
||||
const monitorModule = new MonitorModule({
|
||||
@@ -101,6 +100,7 @@ export const initializeServices = async ({ logger, envSettings, settingsService
|
||||
});
|
||||
const notificationModule = new NotificationModule({ Notification, Monitor });
|
||||
const recoveryModule = new RecoveryModule({ User, RecoveryToken, crypto, stringService });
|
||||
const settingsModule = new SettingsModule({ AppSettings });
|
||||
const incidentModule = new IncidentModule({ logger, Incident, Monitor, User });
|
||||
|
||||
const db = new MongoDB({
|
||||
|
||||
@@ -4,29 +4,8 @@ const SERVICE_NAME = "SettingsModule";
|
||||
class SettingsModule {
|
||||
constructor({ AppSettings }) {
|
||||
this.AppSettings = AppSettings;
|
||||
this.settingsCache = null;
|
||||
this.cacheTimestamp = null;
|
||||
this.CACHE_TTL = 60000; // 1 minute cache
|
||||
}
|
||||
|
||||
getAppSettings = async () => {
|
||||
try {
|
||||
const now = Date.now();
|
||||
if (this.settingsCache && this.cacheTimestamp && (now - this.cacheTimestamp) < this.CACHE_TTL) {
|
||||
return this.settingsCache;
|
||||
}
|
||||
|
||||
const settings = await this.AppSettings.findOne({ singleton: true }).select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
||||
this.settingsCache = settings;
|
||||
this.cacheTimestamp = now;
|
||||
return settings;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "getAppSettings";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
updateAppSettings = async (newSettings) => {
|
||||
try {
|
||||
const update = { $set: { ...newSettings } };
|
||||
@@ -45,11 +24,6 @@ class SettingsModule {
|
||||
upsert: true,
|
||||
});
|
||||
const settings = await this.AppSettings.findOne().select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
||||
|
||||
// Invalidate cache after update
|
||||
this.settingsCache = settings;
|
||||
this.cacheTimestamp = Date.now();
|
||||
|
||||
return settings;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
const SERVICE_NAME = "statusPageModule";
|
||||
|
||||
class StatusPageModule {
|
||||
constructor({ StatusPage, NormalizeData, stringService, settingsModule }) {
|
||||
constructor({ StatusPage, NormalizeData, stringService, AppSettings }) {
|
||||
this.StatusPage = StatusPage;
|
||||
this.NormalizeData = NormalizeData;
|
||||
this.stringService = stringService;
|
||||
this.settingsModule = settingsModule;
|
||||
this.AppSettings = AppSettings;
|
||||
}
|
||||
|
||||
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
|
||||
@@ -260,7 +260,7 @@ class StatusPageModule {
|
||||
|
||||
const { statusPage, monitors } = statusPageQuery[0];
|
||||
|
||||
const appSettings = await this.settingsModule.getAppSettings();
|
||||
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
|
||||
const showURL = appSettings?.showURL === true;
|
||||
|
||||
const normalizedMonitors = monitors.map((monitor) => {
|
||||
|
||||
Reference in New Issue
Block a user