feat: added heath_error_count and the cron for health check agent errors

This commit is contained in:
Charles GTE
2026-03-27 22:13:32 +01:00
parent bded273f94
commit 595ccadfb3
14 changed files with 2674 additions and 103 deletions
+2 -21
View File
@@ -6,27 +6,6 @@ import {eq} from "drizzle-orm";
import * as drizzleDb from "@/db";
export async function sendNotificationsBackupRestore(database: DatabaseWith, event: EventKind) {
// if (!database.alertPolicies || database.alertPolicies.length === 0) {
// return [];
// }
//
// const activePolicies = database.alertPolicies.filter(policy =>
// policy.enabled && policy.eventKinds.includes(event)
// );
//
// const settings = await db.query.setting.findFirst({
// where: eq(drizzleDb.schemas.setting.name, "system"),
// with: {notificationChannel: true},
// });
//
// const defaultPolicy = settings?.notificationChannel
// ? [{
// id: null,
// notificationChannelId: settings.notificationChannel.id,
// enabled: settings.notificationChannel.enabled,
// }]
// : [];
const settings = await db.query.setting.findFirst({
where: eq(drizzleDb.schemas.setting.name, "system"),
@@ -38,6 +17,7 @@ export async function sendNotificationsBackupRestore(database: DatabaseWith, eve
id: null,
notificationChannelId: settings.notificationChannel.id,
enabled: settings.notificationChannel.enabled,
eventKinds: ["error_backup" , "error_restore"]
}]
: [];
@@ -79,6 +59,7 @@ export async function sendNotificationsBackupRestore(database: DatabaseWith, eve
success_backup: `Backup Notification`,
success_restore: `Restore Notification`,
weekly_report: `Weekly Report Notification`,
error_health_agent: "Health Agent Notification",
};
const payload: EventPayload = {
+1 -1
View File
@@ -18,4 +18,4 @@ export interface EventPayload {
data?: Record<string, any>;
}
export type EventKind = ("error_backup" | "error_restore" | "success_restore" | "success_backup" | "weekly_report")
export type EventKind = ("error_backup" | "error_restore" | "success_restore" | "success_backup" | "weekly_report" | "error_health_agent")