use a projected window instead of read/write

This commit is contained in:
Alex Holliday committed 2026-04-16 10:59:30 -07:00
1 parent 8f55d966f9
commit 24d7ead1d1
3 files changed
+61 -48

No files matched your search

@@ -35,7 +35,8 @@ export interface IMonitorsRepository {
status: boolean,
checkSnapshot: CheckSnapshot,
windowSize: number,
maxRecentChecks: number
maxRecentChecks: number,
statusPatch?: Partial<Monitor>
): Promise<Monitor>;
togglePauseById(monitorId: string, teamId: string): Promise<Monitor>;
// delete
@@ -188,7 +188,8 @@ class MongoMonitorsRepository implements IMonitorsRepository {
status: boolean,
checkSnapshot: CheckSnapshot,
windowSize: number,
maxRecentChecks: number
maxRecentChecks: number,
statusPatch?: Partial<Monitor>
): Promise<Monitor> => {
const updatedMonitor = await MonitorModel.findOneAndUpdate(
{ _id: monitorId, teamId },
@@ -197,6 +198,7 @@ class MongoMonitorsRepository implements IMonitorsRepository {
statusWindow: { $each: [status], $slice: -windowSize },
recentChecks: { $each: [checkSnapshot], $slice: -maxRecentChecks },
},
...(statusPatch && { $set: statusPatch }),
},
{ returnDocument: "after" }
);