Quick vote logging, changed data.json save path to qminingPublic

This commit is contained in:
MrFry 2020-04-20 22:16:01 +02:00
parent bd8e46f6c7
commit 26830f0116
4 changed files with 7 additions and 4 deletions

View file

@ -134,6 +134,7 @@ function GetApp () {
app.get('/quickvote', (req, res) => {
const key = req.query.key
const val = req.query.val
const user = req.session.user
if (!key || !val) {
res.render('votethank', {
@ -147,6 +148,7 @@ function GetApp () {
if (utils.FileExists(quickVotes)) {
votes = utils.ReadJSON(quickVotes)
} else {
logger.Log(`No such vote "${key}", and quickVotes.json is missing ( #${user.id}: ${key}-${val} )`, logger.GetColor('blue'))
res.render('votethank', {
result: 'no such pool'
})
@ -154,6 +156,7 @@ function GetApp () {
}
if (!votes.voteNames.includes(key)) {
logger.Log(`No such vote "${key}" ( #${user.id}: ${key}-${val} )`, logger.GetColor('blue'))
res.render('votethank', {
result: 'no such pool'
})
@ -161,7 +164,6 @@ function GetApp () {
}
const voteFile = quickVoteResultsDir + '/' + key + '.json'
const user = req.session.user
let voteData = {
votes: {},
@ -175,7 +177,7 @@ function GetApp () {
}
if (!voteData.users.includes(user.id)) {
if (voteData[val]) {
if (voteData.votes[val]) {
voteData.votes[val]++
} else {
voteData.votes[val] = 1