mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Quick vote logging, changed data.json save path to qminingPublic
This commit is contained in:
parent
bd8e46f6c7
commit
26830f0116
4 changed files with 7 additions and 4 deletions
|
@ -18,6 +18,7 @@ module.exports = function (options) {
|
||||||
logger.Log('Hostname is undefined!', logger.GetColor('redbg'))
|
logger.Log('Hostname is undefined!', logger.GetColor('redbg'))
|
||||||
console.log(req.body)
|
console.log(req.body)
|
||||||
console.log(req.query)
|
console.log(req.query)
|
||||||
|
console.log(req.headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: regexp includes checking
|
// fixme: regexp includes checking
|
||||||
|
|
|
@ -134,6 +134,7 @@ function GetApp () {
|
||||||
app.get('/quickvote', (req, res) => {
|
app.get('/quickvote', (req, res) => {
|
||||||
const key = req.query.key
|
const key = req.query.key
|
||||||
const val = req.query.val
|
const val = req.query.val
|
||||||
|
const user = req.session.user
|
||||||
|
|
||||||
if (!key || !val) {
|
if (!key || !val) {
|
||||||
res.render('votethank', {
|
res.render('votethank', {
|
||||||
|
@ -147,6 +148,7 @@ function GetApp () {
|
||||||
if (utils.FileExists(quickVotes)) {
|
if (utils.FileExists(quickVotes)) {
|
||||||
votes = utils.ReadJSON(quickVotes)
|
votes = utils.ReadJSON(quickVotes)
|
||||||
} else {
|
} else {
|
||||||
|
logger.Log(`No such vote "${key}", and quickVotes.json is missing ( #${user.id}: ${key}-${val} )`, logger.GetColor('blue'))
|
||||||
res.render('votethank', {
|
res.render('votethank', {
|
||||||
result: 'no such pool'
|
result: 'no such pool'
|
||||||
})
|
})
|
||||||
|
@ -154,6 +156,7 @@ function GetApp () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!votes.voteNames.includes(key)) {
|
if (!votes.voteNames.includes(key)) {
|
||||||
|
logger.Log(`No such vote "${key}" ( #${user.id}: ${key}-${val} )`, logger.GetColor('blue'))
|
||||||
res.render('votethank', {
|
res.render('votethank', {
|
||||||
result: 'no such pool'
|
result: 'no such pool'
|
||||||
})
|
})
|
||||||
|
@ -161,7 +164,6 @@ function GetApp () {
|
||||||
}
|
}
|
||||||
|
|
||||||
const voteFile = quickVoteResultsDir + '/' + key + '.json'
|
const voteFile = quickVoteResultsDir + '/' + key + '.json'
|
||||||
const user = req.session.user
|
|
||||||
|
|
||||||
let voteData = {
|
let voteData = {
|
||||||
votes: {},
|
votes: {},
|
||||||
|
@ -175,7 +177,7 @@ function GetApp () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!voteData.users.includes(user.id)) {
|
if (!voteData.users.includes(user.id)) {
|
||||||
if (voteData[val]) {
|
if (voteData.votes[val]) {
|
||||||
voteData.votes[val]++
|
voteData.votes[val]++
|
||||||
} else {
|
} else {
|
||||||
voteData.votes[val] = 1
|
voteData.votes[val] = 1
|
||||||
|
|
|
@ -22,7 +22,7 @@ module.exports = {
|
||||||
LoadJSON: LoadJSON
|
LoadJSON: LoadJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataFile = './public/data.json'
|
const dataFile = './qminingPublic/data.json'
|
||||||
const recDataFile = './stats/recdata'
|
const recDataFile = './stats/recdata'
|
||||||
|
|
||||||
const logger = require('../utils/logger.js')
|
const logger = require('../utils/logger.js')
|
||||||
|
|
|
@ -18,7 +18,7 @@ var fs = require('fs')
|
||||||
|
|
||||||
var logger = require('../utils/logger.js')
|
var logger = require('../utils/logger.js')
|
||||||
|
|
||||||
const dataFile = './public/data.json'
|
const dataFile = './qminingPublic/data.json'
|
||||||
|
|
||||||
function GetDateString () {
|
function GetDateString () {
|
||||||
const m = new Date()
|
const m = new Date()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue