diff options
| author | Zephyrrus <[email protected]> | 2021-01-07 21:36:56 +0200 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2021-01-07 21:36:56 +0200 |
| commit | b3df1dd7a653909fb3f18ed7c0c91ffa347480fb (patch) | |
| tree | 785a168e85aa6ebe7e8e7e8ea4a3f54dbe3c7efc /src/api/routes/admin/statsGET.js | |
| parent | chore: update knex, mdi/font, nuxtjs/axios, nuxt, systeminformation (diff) | |
| download | host.fuwn.me-b3df1dd7a653909fb3f18ed7c0c91ffa347480fb.tar.xz host.fuwn.me-b3df1dd7a653909fb3f18ed7c0c91ffa347480fb.zip | |
feat: change mutation timestamp on every database mutation
Diffstat (limited to 'src/api/routes/admin/statsGET.js')
| -rw-r--r-- | src/api/routes/admin/statsGET.js | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/api/routes/admin/statsGET.js b/src/api/routes/admin/statsGET.js deleted file mode 100644 index 388d4fa..0000000 --- a/src/api/routes/admin/statsGET.js +++ /dev/null @@ -1,34 +0,0 @@ -const Route = require('../../structures/Route'); -const StatsGenerator = require('../../utils/StatsGenerator'); - -// Thank you Bobby for the stats code https://github.com/BobbyWibowo/lolisafe/blob/safe.fiery.me/controllers/utilsController.js -class filesGET extends Route { - constructor() { - super('/admin/stats', 'get', { adminOnly: true }); - } - - async run(req, res, db) { - const cachedStats = await db('statistics') - .select('type', 'data', 'batchId') - .where('batchId', '=', db('statistics').max('batchId')); - - let stats = cachedStats.reduce((acc, { type, data }) => { - try { - acc[type] = JSON.parse(data); - } catch (e) { - console.error(e); - } - - return acc; - }, {}); - - stats = { ...stats, ...(await StatsGenerator.getMissingStats(db, Object.keys(stats))) }; - - return res.json(StatsGenerator.keyOrder.reduce((acc, k) => { - acc[k] = stats[k]; - return acc; - }, {})); - } -} - -module.exports = filesGET; |