mirror of
https://git.femboyfinancial.jp/james/FemScoreboard.git
synced 2026-02-14 18:49:56 -08:00
Improved sync logic, show more statistics, bug fixes
This commit is contained in:
17
server.ts
17
server.ts
@@ -19,17 +19,20 @@ async function openDb() {
|
||||
return open({
|
||||
filename: 'discord/db.sqlite',
|
||||
driver: Database3
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/', async (req, res) => {
|
||||
const users = await db.all<[ScoreboardUserRow]>('SELECT * FROM users');
|
||||
//const msgs = await db.all<[ScoreboardMessageRow]>('SELECT * FROM messages');
|
||||
const msg1 = await db.all<[ScoreboardMessageRow]>('SELECT * FROM messages ORDER BY reaction_1_count DESC LIMIT 5');
|
||||
const msg2 = await db.all<[ScoreboardMessageRow]>('SELECT * FROM messages ORDER BY reaction_2_count DESC LIMIT 5');
|
||||
const msg3 = await db.all<[ScoreboardMessageRow]>('SELECT * FROM messages ORDER BY reaction_3_count DESC LIMIT 5');
|
||||
const bestMsg = await db.all<[ScoreboardMessageRow]>('SELECT *, SUM(reaction_1_count)+SUM(reaction_2_count)+SUM(reaction_3_count) AS all_reacts FROM messages GROUP BY id ORDER BY all_reacts DESC LIMIT 5');
|
||||
|
||||
const funniest = [...users].sort((a, b) => a.reaction_1_total - b.reaction_1_total);
|
||||
const realest = [...users].sort((a, b) => a.reaction_2_total - b.reaction_2_total);
|
||||
const cunniest = [...users].sort((a, b) => a.reaction_3_total - b.reaction_3_total);
|
||||
res.render('index', { funniest, realest, cunniest });
|
||||
const funniest = await db.all<[ScoreboardUserRow]>('SELECT * FROM users ORDER BY reaction_1_total DESC');
|
||||
const realest = await db.all<[ScoreboardUserRow]>('SELECT * FROM users ORDER BY reaction_2_total DESC');
|
||||
const cunniest = await db.all<[ScoreboardUserRow]>('SELECT * FROM users ORDER BY reaction_3_total DESC');
|
||||
|
||||
res.render('index', { funniest, realest, cunniest, msg1, msg2, msg3, bestMsg });
|
||||
});
|
||||
|
||||
app.listen(port, async () => {
|
||||
|
||||
Reference in New Issue
Block a user