aboutsummaryrefslogtreecommitdiff
path: root/admin/index.js
diff options
context:
space:
mode:
authorMarvin Borner2021-01-26 13:12:41 +0100
committerMarvin Borner2021-01-26 13:12:41 +0100
commit39652bd9c908247139d177b02f1126cb5e07c119 (patch)
treee6e42a16249e9d15dececd451ec923c56837be15 /admin/index.js
parent40035bd9cea21c4173f6727ba54d94f4fde44a9c (diff)
Some minor changes lol
Diffstat (limited to 'admin/index.js')
-rw-r--r--admin/index.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/admin/index.js b/admin/index.js
index a67b9f3..46b4f16 100644
--- a/admin/index.js
+++ b/admin/index.js
@@ -39,9 +39,16 @@ app.get("/api/all", checkAdmin, async (req, res) => {
res.json(all);
});
+app.get("/api/percentages", checkAdmin, async (req, res) => {
+ const percentages = await db.query(
+ "SELECT q.id, q.question question, o.answer_option option, COUNT(a.user_id) count FROM question_questions q INNER JOIN question_options o ON q.id = o.question_id INNER JOIN question_answers a ON o.id = a.option_id GROUP BY o.id",
+ );
+ res.json(percentages);
+});
+
app.get("/api/questions", checkAdmin, async (req, res) => {
const questions = await db.query(
- "SELECT q.id, question, t.name type FROM ranking_questions q INNER JOIN types t on type_id = t.id ORDER BY q.id",
+ "SELECT q.id, question, t.name type FROM ranking_questions q INNER JOIN types t ON type_id = t.id ORDER BY q.id",
);
res.json(questions);
});