add last evaluated at field

This commit is contained in:
Alex Holliday committed 2026-06-11 14:18:32 -07:00
1 parent c882daf000
commit 8dedf2a742
4 files changed
+9

No files matched your search

@@ -34,6 +34,7 @@ interface MonitorDocument extends MonitorDocumentBase {
teamId: Types.ObjectId; teamId: Types.ObjectId;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
lastEvaluatedAt: number; // epoch ms
} }
const snapshotTimingPhasesSchema = new Schema<GotTimings["phases"]>( const snapshotTimingPhasesSchema = new Schema<GotTimings["phases"]>(
@@ -377,6 +378,10 @@ const MonitorSchema = new Schema<MonitorDocument>(
type: [checkSnapshotSchema], type: [checkSnapshotSchema],
default: [], default: [],
}, },
lastEvaluatedAt: {
type: Number,
default: 0,
},
}, },
{ {
timestamps: true, timestamps: true,
@@ -571,6 +571,7 @@ class MongoMonitorsRepository implements IMonitorsRepository {
dnsRecordType: doc.dnsRecordType ?? undefined, dnsRecordType: doc.dnsRecordType ?? undefined,
createdAt: toDateString(doc.createdAt), createdAt: toDateString(doc.createdAt),
updatedAt: toDateString(doc.updatedAt), updatedAt: toDateString(doc.updatedAt),
lastEvaluatedAt: doc.lastEvaluatedAt,
}; };
}; };
@@ -636,6 +637,7 @@ class MongoMonitorsRepository implements IMonitorsRepository {
dnsRecordType: doc.dnsRecordType ?? undefined, dnsRecordType: doc.dnsRecordType ?? undefined,
createdAt: toDateString(doc.createdAt), createdAt: toDateString(doc.createdAt),
updatedAt: toDateString(doc.updatedAt), updatedAt: toDateString(doc.updatedAt),
lastEvaluatedAt: doc.lastEvaluatedAt,
}; };
}; };
@@ -597,6 +597,7 @@ export class MonitorService implements IMonitorService {
recentChecks: [], recentChecks: [],
createdAt: "", createdAt: "",
updatedAt: "", updatedAt: "",
lastEvaluatedAt: 0,
})); }));
const createdMonitors = await this.createMonitors(cleanedMonitors); const createdMonitors = await this.createMonitors(cleanedMonitors);
@@ -88,6 +88,7 @@ export interface Monitor {
recentChecks: CheckSnapshot[]; recentChecks: CheckSnapshot[];
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
lastEvaluatedAt: number; // epoch ms
} }
export interface MonitorsSummary { export interface MonitorsSummary {