fix initializing stats
This commit is contained in:
1 parent
dfc1733820
commit
13251ca7c5
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,
|
||||||
|
|||||||
Reference in new issue
Block a user