From 7a84ad7684dd7a60e07ad262da94da7ebcd0c340 Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 5 Jan 2020 17:32:01 +0100 Subject: [PATCH] do not update rankings too soon, it causes database errors if models aren't synced yet --- src/core/ranking.js | 1 - src/web.js | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ranking.js b/src/core/ranking.js index b136eaf..4da82b0 100644 --- a/src/core/ranking.js +++ b/src/core/ranking.js @@ -18,7 +18,6 @@ class Ranks { this.resetDailyRanking = this.resetDailyRanking.bind(this); this.ranks = {}; - this.updateRanking(); setInterval(this.updateRanking, 5 * MINUTE); DailyCron.hook(this.resetDailyRanking); } diff --git a/src/web.js b/src/web.js index b0354db..b5142a7 100644 --- a/src/web.js +++ b/src/web.js @@ -11,6 +11,7 @@ import etag from 'etag'; import forceGC from './core/forceGC'; import assets from './assets.json'; // eslint-disable-line import/no-unresolved import logger from './core/logger'; +import rankings from './core/ranking'; import models from './data/models'; import { @@ -166,6 +167,7 @@ app.get('/', async (req, res) => { const promise = models.sync().catch((err) => logger.error(err.stack)); promise.then(() => { server.listen(PORT, () => { + rankings.updateRanking(); const address = server.address(); logger.log('info', `web is running at http://localhost:${address.port}/`); });