initial commit

This commit is contained in:
Alex Holliday committed 2026-01-27 18:26:31 +00:00
1 parent 5729b0a263
commit 50c644231e
9 files changed
+72 -21

No files matched your search

@@ -1,4 +1,5 @@
import { requireTeamId } from "@/controllers/controllerUtils.js";
import { Types } from "mongoose";
import { IChecksRepository, IMonitorsRepository } from "@/repositories/index.js";
import type { MonitorType, MonitorStatusResponse, CheckErrorInfo, Check } from "@/types/index.js";
import type { HardwareStatusPayload, PageSpeedStatusPayload } from "@/types/network.js";
@@ -39,6 +40,8 @@ class CheckService {
const { monitorId, teamId, type, status, responseTime, code, message, payload, timings } = statusResponse;
const check: Partial<Check> = {
id: new Types.ObjectId().toString(),
createdAt: new Date().toISOString(),
metadata: {
monitorId,
teamId,
@@ -360,16 +360,12 @@ export class MonitorService implements IMonitorService {
const snapshotOnlyRequest =
requestedTypes.length > 0 && requestedTypes.every((requestedType) => snapshotTypes.includes(requestedType as MonitorType));
const limitPerMonitor = snapshotOnlyRequest ? 1 : 25;
const checksMap = await this.checksRepository.findLatestByMonitorIds(
monitorsList.map((monitor) => monitor.id),
{ limitPerMonitor }
);
const monitorsWithChecks = monitorsList.map((monitor: Monitor) => {
const rawChecks = checksMap[monitor.id] ?? [];
const rawChecks = monitor.recentChecks ?? [];
const isSnapshotType = snapshotOnlyRequest || snapshotTypes.includes(monitor.type);
const checks = isSnapshotType ? rawChecks.slice(0, 1) : NormalizeData(rawChecks, 10, 100);
// recentChecks are stored oldest-first, reverse to get newest-first for display
const reversedChecks = [...rawChecks].reverse();
const checks = isSnapshotType ? reversedChecks.slice(0, 1) : NormalizeData(reversedChecks, 10, 100);
return {
...monitor,
checks,