|
|
@ -137,10 +137,10 @@ export async function logToDb(message: string): Promise<void> { |
|
|
|
|
|
|
|
try { |
|
|
|
// Try to insert first, if it fails due to UNIQUE constraint, update instead
|
|
|
|
await platform.dbExec("INSERT INTO logs (date, message) VALUES (?, ?)", [ |
|
|
|
nowKey, |
|
|
|
message, |
|
|
|
]); |
|
|
|
// await platform.dbExec("INSERT INTO logs (date, message) VALUES (?, ?)", [
|
|
|
|
// nowKey,
|
|
|
|
// message,
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
// Clean up old logs (keep only last 7 days) - do this less frequently
|
|
|
|
// Only clean up if the date is different from the last cleanup
|
|
|
@ -148,9 +148,9 @@ export async function logToDb(message: string): Promise<void> { |
|
|
|
const sevenDaysAgo = new Date( |
|
|
|
new Date().getTime() - 7 * 24 * 60 * 60 * 1000, |
|
|
|
); |
|
|
|
await platform.dbExec("DELETE FROM logs WHERE date < ?", [ |
|
|
|
sevenDaysAgo.toDateString(), |
|
|
|
]); |
|
|
|
// await platform.dbExec("DELETE FROM logs WHERE date < ?", [
|
|
|
|
// sevenDaysAgo.toDateString(),
|
|
|
|
// ]);
|
|
|
|
lastCleanupDate = todayKey; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|