From 2c1ccd05572212f98d7a9e0a11e5c4aabacd65eb Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 29 Jan 2021 23:17:43 +0100 Subject: [PATCH] prune state.json --- packages/health-check/src/run.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/health-check/src/run.js b/packages/health-check/src/run.js index fdabdea9..95a7b5a1 100644 --- a/packages/health-check/src/run.js +++ b/packages/health-check/src/run.js @@ -1,3 +1,5 @@ +const { getYesterdayISOString } = require("./utils"); + require("yargs/yargs")(process.argv.slice(2)).command( "$0 ", "Skynet portal health checks", @@ -31,7 +33,10 @@ require("yargs/yargs")(process.argv.slice(2)).command( checks: await Promise.all(checks.map((check) => new Promise(check))), }; - // read before writing to make sure no external changes are overwritten - db.read().get(type).push(entry).write(); + db.read() // read before writing to make sure no external changes are overwritten + .get(type) // get the list of records of given type + .push(entry) // insert new record + .remove(({ date }) => date < getYesterdayISOString()) // drop old records + .write(); } ).argv;