Merge pull request #3008 from bluewave-labs/feat/v2/uptime-details

feat/v2/uptime details
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-10-08 13:48:05 -07:00
commit 0a5efc75cd
39 files changed
+1540 -110

No files matched your search

@@ -5,6 +5,7 @@ import { MonitorType } from "../../../db/v2/models/monitors/Monitor.js";
import { StatusResponse } from "../infrastructure/NetworkService.js";
import type { ICapturePayload, ILighthousePayload } from "../infrastructure/NetworkService.js";
import mongoose from "mongoose";
import { stat } from "fs";
const SERVICE_NAME = "CheckServiceV2";
export interface ICheckService {
@@ -60,6 +61,7 @@ class CheckService implements ICheckService {
monitorId: monitorId,
type: statusResponse?.type,
status: statusResponse?.status,
httpStatusCode: statusResponse?.code,
message: statusResponse?.message,
responseTime: statusResponse?.responseTime,
timings: statusResponse?.timings,
@@ -130,6 +132,16 @@ class CheckService implements ICheckService {
return false;
}
};
getChecks = async (monitorId: string, page: number, rowsPerPage: number) => {
const count = await Check.countDocuments({ monitorId: new mongoose.Types.ObjectId(monitorId) });
const checks = await Check.find({ monitorId: new mongoose.Types.ObjectId(monitorId) })
.sort({ createdAt: -1 })
.skip(page * rowsPerPage)
.limit(rowsPerPage)
.exec();
return { checks, count };
};
}
export default CheckService;
@@ -63,8 +63,8 @@ class MonitorService implements IMonitorService {
private getStartDate(range: string): Date {
const now = new Date();
switch (range) {
case "30m":
return new Date(now.getTime() - 30 * 60 * 1000);
case "2h":
return new Date(now.getTime() - 2 * 60 * 60 * 1000);
case "24h":
return new Date(now.getTime() - 24 * 60 * 60 * 1000);
case "7d":
@@ -78,7 +78,7 @@ class MonitorService implements IMonitorService {
private getDateFormat(range: string): string {
switch (range) {
case "30m":
case "2h":
return "%Y-%m-%dT%H:%M:00Z";
case "24h":
case "7d":