don't try to save undefined data in status

This commit is contained in:
Madeline 2022-07-22 19:58:52 +10:00
parent 4486627240
commit 2a0b8cf9f5

View File

@ -42,7 +42,7 @@ client.on("warn", (msg) => {
const savePerf = async (time: number, name: string, error?: string | Error) => { const savePerf = async (time: number, name: string, error?: string | Error) => {
if (error && typeof error != "string") error = error.message; if (error && typeof error != "string") error = error.message;
try { try {
await executePromise("INSERT INTO performance (value, endpoint, timestamp, error) VALUES (?, ?, ?, ?)", [time, name, new Date(), error ?? null]); await executePromise("INSERT INTO performance (value, endpoint, timestamp, error) VALUES (?, ?, ?, ?)", [time ?? 0, name, new Date(), error ?? null]);
await executePromise("DELETE FROM performance WHERE DATE(timestamp) < now() - interval ? DAY", [process.env.RETENTION_DAYS]); await executePromise("DELETE FROM performance WHERE DATE(timestamp) < now() - interval ? DAY", [process.env.RETENTION_DAYS]);
} }
catch (e) { catch (e) {