From ca37e388006eb982ba50f7fa8d10d700fde60741 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Fri, 28 Aug 2020 17:39:47 +0200 Subject: [PATCH] schedule database cleanup --- lib/db/index.js | 3 +++ lib/db/job.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/db/index.js b/lib/db/index.js index 87c7f85..5026972 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -38,6 +38,9 @@ async function init (use_fake_seed) { // await db.seed.run ({ specific: 'fake.js' }); await job (db); + setInterval (() => { + job (db); + }, 3600e3); } function get_db () { diff --git a/lib/db/job.js b/lib/db/job.js index 8733883..3148c0d 100644 --- a/lib/db/job.js +++ b/lib/db/job.js @@ -40,6 +40,8 @@ async function batch_update (knex, ids, data) { } module.exports = async (knex) => { + console.log ('-- running database cleanup --'); + const apps = await knex ('app') .select ('id', 'name', 'reduction');