Merge pull request #3282 from bluewave-labs/fix/monitor-stats

fix: initializing stats
This commit is contained in:
Alexander Holliday authored and GitHub committed 2026-02-13 11:18:54 -08:00
commit 88fceddbbf
1 file changed
+12 -1
@@ -52,7 +52,18 @@ export class StatusService implements IStatusService {
try { try {
const monitorId = monitor.id; const monitorId = monitor.id;
const { responseTime, status } = networkResponse; const { responseTime, status } = networkResponse;
let stats: Omit<MonitorStats, "id" | "createdAt" | "updatedAt"> = await this.monitorStatsRepository.findByMonitorId(monitorId); let stats: Omit<MonitorStats, "id" | "createdAt" | "updatedAt"> | null = null;
stats = await this.monitorStatsRepository
.findByMonitorId(monitorId)
.then((result) => result)
.catch(() => {
this.logger.debug({
service: SERVICE_NAME,
method: "updateRunningStats",
message: `No existing stats found for monitor ${monitorId}, initializing new stats.`,
});
return null;
});
if (!stats) { if (!stats) {
stats = { stats = {
monitorId, monitorId,