convert checkModule to class for dependency injection

This commit is contained in:
Alex Holliday committed 2025-07-29 11:51:06 -07:00
1 parent 9d94b71583
commit e55d8618bd
6 files changed
+300 -369

No files matched your search

+8 -8
View File
@@ -34,7 +34,7 @@ class CheckService {
}
let { type, sortOrder, dateRange, filter, ack, page, rowsPerPage, status } = query;
const result = await this.db.getChecksByMonitor({
const result = await this.db.checkModule.getChecksByMonitor({
monitorId,
type,
sortOrder,
@@ -55,7 +55,7 @@ class CheckService {
throw this.errorService.createBadRequestError("No team ID in request");
}
const checkData = await this.db.getChecksByTeam({
const checkData = await this.db.checkModule.getChecksByTeam({
sortOrder,
dateRange,
filter,
@@ -72,7 +72,7 @@ class CheckService {
throw this.errorService.createBadRequestError("No team ID in request");
}
const summary = await this.db.getChecksSummaryByTeamId({ teamId });
const summary = await this.db.checkModule.getChecksSummaryByTeamId({ teamId });
return summary;
};
@@ -85,7 +85,7 @@ class CheckService {
throw this.errorService.createBadRequestError("No team ID in request");
}
const updatedCheck = await this.db.ackCheck(checkId, teamId, ack);
const updatedCheck = await this.db.checkModule.ackCheck(checkId, teamId, ack);
return updatedCheck;
};
@@ -105,7 +105,7 @@ class CheckService {
}
}
const updatedChecks = await this.db.ackAllChecks(monitorId, teamId, ack, path);
const updatedChecks = await this.db.checkModule.ackAllChecks(monitorId, teamId, ack, path);
return updatedChecks;
};
@@ -128,7 +128,7 @@ class CheckService {
throw this.errorService.createAuthorizationError();
}
const deletedCount = await this.db.deleteChecks(monitorId);
const deletedCount = await this.db.checkModule.deleteChecks(monitorId);
return deletedCount;
};
deleteChecksByTeamId = async ({ teamId }) => {
@@ -136,14 +136,14 @@ class CheckService {
throw this.errorService.createBadRequestError("No team ID in request");
}
const deletedCount = await this.db.deleteChecksByTeamId(teamId);
const deletedCount = await this.db.checkModule.deleteChecksByTeamId(teamId);
return deletedCount;
};
updateChecksTTL = async ({ teamId, ttl }) => {
const SECONDS_PER_DAY = 86400;
const newTTL = parseInt(ttl, 10) * SECONDS_PER_DAY;
await this.db.updateChecksTTL(teamId, newTTL);
await this.db.checkModule.updateChecksTTL(teamId, newTTL);
};
}
@@ -153,7 +153,7 @@ class MonitorService {
monitors.map(async (monitor) => {
try {
await this.jobQueue.deleteJob(monitor);
await this.db.deleteChecks(monitor._id);
await this.db.checkModule.deleteChecks(monitor._id);
await this.db.deletePageSpeedChecksByMonitorId(monitor._id);
await this.db.deleteNotificationsByMonitorId(monitor._id);
} catch (error) {
@@ -21,7 +21,7 @@ class BufferService {
hardwareChecks: [],
};
this.OPERATION_MAP = {
checks: this.db.createChecks,
checks: this.db.checkModule.createChecks,
pagespeedChecks: this.db.createPageSpeedChecks,
hardwareChecks: this.db.createHardwareChecks,
};