feat(catalog-backend): delete log entries older than a cutoff

This commit is contained in:
Fredrik Adelöw
2020-09-18 13:57:43 +02:00
parent ddc1cbd96a
commit 082d8b0bfd
@@ -343,7 +343,14 @@ export class CommonDatabase implements Database {
entityName?: string,
message?: string,
): Promise<void> {
return this.database<DatabaseLocationUpdateLogEvent>(
// Remove log entries older than a day
const cutoff = new Date();
cutoff.setDate(cutoff.getDate() - 1);
await this.database<DatabaseLocationUpdateLogEvent>('location_update_log')
.where('created_at', '<', cutoff.toISOString())
.del();
await this.database<DatabaseLocationUpdateLogEvent>(
'location_update_log',
).insert({
status,