aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/admin
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/admin')
-rw-r--r--src/api/routes/admin/statsGET.js34
-rw-r--r--src/api/routes/admin/userDemote.js3
-rw-r--r--src/api/routes/admin/userDisable.js3
-rw-r--r--src/api/routes/admin/userEnable.js3
4 files changed, 6 insertions, 37 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;
diff --git a/src/api/routes/admin/userDemote.js b/src/api/routes/admin/userDemote.js
index b430a48..6611d9f 100644
--- a/src/api/routes/admin/userDemote.js
+++ b/src/api/routes/admin/userDemote.js
@@ -14,7 +14,8 @@ class userDemote extends Route {
try {
await db.table('users')
.where({ id })
- .update({ isAdmin: false });
+ .update({ isAdmin: false })
+ .wasMutated();
} catch (error) {
return super.error(res, error);
}
diff --git a/src/api/routes/admin/userDisable.js b/src/api/routes/admin/userDisable.js
index e39c811..a3dbb15 100644
--- a/src/api/routes/admin/userDisable.js
+++ b/src/api/routes/admin/userDisable.js
@@ -14,7 +14,8 @@ class userDisable extends Route {
try {
await db.table('users')
.where({ id })
- .update({ enabled: false });
+ .update({ enabled: false })
+ .wasMutated();
} catch (error) {
return super.error(res, error);
}
diff --git a/src/api/routes/admin/userEnable.js b/src/api/routes/admin/userEnable.js
index cff622f..47a9dcb 100644
--- a/src/api/routes/admin/userEnable.js
+++ b/src/api/routes/admin/userEnable.js
@@ -14,7 +14,8 @@ class userEnable extends Route {
try {
await db.table('users')
.where({ id })
- .update({ enabled: true });
+ .update({ enabled: true })
+ .wasMutated();
} catch (error) {
return super.error(res, error);
}