aboutsummaryrefslogtreecommitdiff
path: root/src/server.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2019-04-06 15:27:13 -0400
committerMark Powers <markppowers0@gmail.com>2019-04-06 15:27:13 -0400
commit7d0aa00e74b1ed2ea2cab9afaf8eb7b7f9280d3d (patch)
tree73ce87ec71409573e9c1d508c696caa8ba5c24a7 /src/server.js
parentfd40608784ad428822e7c3ea02d35bca196966fd (diff)
Filter sessions in admin
Diffstat (limited to 'src/server.js')
-rw-r--r--src/server.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/server.js b/src/server.js
index 06a3ec5..eae99e4 100644
--- a/src/server.js
+++ b/src/server.js
@@ -96,10 +96,11 @@ function setUpRoutes(models, jwtFunctions, database) {
})
server.get('/admin/stats', async (req, res, next) => {
try {
- var sessionResult = await database.query("SELECT session, count(id) as c FROM requests GROUP BY session", { type: database.QueryTypes.SELECT })
+ var sessionResult = await database.query("SELECT session, count(id) as c FROM requests GROUP BY session HAVING c > 1", { type: database.QueryTypes.SELECT })
+ var total = await database.query("select count(distinct session) as t FROM requests", { type: database.QueryTypes.SELECT })
var urlResult = await database.query("SELECT method, url, count(id) as c FROM requests GROUP BY method, url", { type: database.QueryTypes.SELECT })
var logResult = await database.query("SELECT createdAt, session, method, url FROM requests order by createdAt desc limit 15", { type: database.QueryTypes.SELECT })
- res.status(200).send({ session: sessionResult, url: urlResult, log: logResult });
+ res.status(200).send({ total: total[0].t, session: sessionResult, url: urlResult, log: logResult });
next();
} catch (e) {
res.status(400).send(e.message);