- Activity page: "Delete all" empties the open tab (api/admin/logs/clear-logs, super admin only, logged under system) - Stop logging every WebSocket connect - Log unexpected API errors (safeErrorMessage -> logUnexpectedError), every failed bot job attempt and every job the queue lost - Drop the cron jobs' console output; a failed model sync goes to the logs Co-Authored-By: Claude Opus 5.5 <[email protected]>
19 lines
625 B
TypeScript
19 lines
625 B
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import { AppData } from "@/src/data/app-data";
|
|
|
|
/**
|
|
* Deletes finished jobs (completed, failed or cancelled) older than
|
|
* `AppData.BotQueueRetentionDays`. Their messages stay in the conversation.
|
|
*/
|
|
export default async function pruneBotsQueue() {
|
|
const cutoff =
|
|
Date.now() - AppData.BotQueueRetentionDays * 24 * 60 * 60 * 1000;
|
|
|
|
const res = await BunSQLite.sql({
|
|
sql: `DELETE FROM bots_queue WHERE status IN ('completed', 'failed') AND finished_at IS NOT NULL AND finished_at < ? RETURNING id`,
|
|
values: [cutoff],
|
|
});
|
|
|
|
return res;
|
|
}
|