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:
@@ -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
|
||||
|
Reference in New Issue
Block a user