mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added ranklist
This commit is contained in:
parent
17526a14de
commit
13a18c3fd8
1 changed files with 27 additions and 0 deletions
|
@ -43,6 +43,7 @@ const usersDbBackupPath = 'data/dbs/backup'
|
|||
const quickVoteResultsDir = 'stats/qvote'
|
||||
const quickVotes = 'stats/qvote/votes.json'
|
||||
const testUsersFile = 'data/testUsers.json'
|
||||
const idStatFile = 'stats/idstats'
|
||||
|
||||
// other constants
|
||||
const maxVeteranPwGetCount = 10
|
||||
|
@ -161,6 +162,32 @@ function GetApp() {
|
|||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
app.get('/ranklist', (req, res) => {
|
||||
const user = req.session.user
|
||||
const data = utils.ReadJSON(idStatFile)
|
||||
|
||||
const list = []
|
||||
|
||||
Object.keys(data).forEach((key) => {
|
||||
list.push({
|
||||
userId: parseInt(key),
|
||||
...data[key],
|
||||
})
|
||||
})
|
||||
|
||||
if (list.length === 0) {
|
||||
res.json({
|
||||
msg: 'There are no users in the stats db :c',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
res.json({
|
||||
list: list,
|
||||
selfuserId: user.id,
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/quickvote', (req, res) => {
|
||||
const key = req.query.key
|
||||
const val = req.query.val
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue