Feat: Summary for Incidents

This commit is contained in:
Br0wnHammer committed 2025-07-01 17:55:50 +05:30
1 parent 35a9c081b5
commit 5428999d46
4 files changed
+85 -8

No files matched your search

+23
View File
@@ -5,6 +5,7 @@ import PageSpeedCheck from "../../models/PageSpeedCheck.js";
import User from "../../models/User.js";
import logger from "../../../utils/logger.js";
import { ObjectId } from "mongodb";
import { buildChecksAndSummaryByTeamIdPipeline } from "./checkModuleQueries.js";
const SERVICE_NAME = "checkModule";
const dateRangeLookup = {
@@ -304,6 +305,27 @@ const ackAllChecks = async (monitorId, teamId, ack, path) => {
}
};
/**
* Get checks and summary by team ID
* @async
* @param {string} teamId
* @returns {Promise<Object>}
* @throws {Error}
*/
const getChecksAndSummaryByTeamId = async ({ teamId }) => {
try {
const matchStage = {
teamId: new ObjectId(teamId),
}
const checks = await Check.aggregate(buildChecksAndSummaryByTeamIdPipeline({ matchStage }));
return checks[0].summary;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getChecksAndSummaryByTeamId";
throw error;
}
};
/**
* Delete all checks for a monitor
* @async
@@ -387,6 +409,7 @@ export {
getChecksByTeam,
ackCheck,
ackAllChecks,
getChecksAndSummaryByTeamId,
deleteChecks,
deleteChecksByTeamId,
updateChecksTTL,