Commit 65845954 authored by Dennis Willers's avatar Dennis Willers 🏀

Fix Vote Update Bug

parent 238b8299
Pipeline #430 passed with stages
in 2 minutes and 43 seconds
......@@ -33,7 +33,6 @@ function createRouter(db) {
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error in hasMap'});
} else {
numberResults = results[0].Maps;
console.log(numberResults);
if (numberResults === 1) next();
else if (numberResults === 0) addMap(req, res, next);
else res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'There are multiple maps with the same id'});
......@@ -113,7 +112,7 @@ function createRouter(db) {
const userId = req.body.userId;
const mapId = req.body.mapId;
const vote = req.body.vote;
const sql = 'UPDATE Vote SET userId = \"'+ userId + '\", mapId = \"'+ mapId + '\", vote = \"' + vote +'\" WHERE userID = \"'+ userId +'\";';
const sql = 'UPDATE Vote SET userId = \"'+ userId + '\", mapId = \"'+ mapId + '\", vote = \"' + vote +'\" WHERE userID = \"'+ userId +'\" AND mapId = \"' + mapId + '\";';
console.log('Update Vote: ', sql);
db.query(
sql,
......
......@@ -31,6 +31,10 @@ function sendRequest(url, json, callback) {
});
}
/*function addMapToClient(clintList, client, mapId) {
const clientId = client.name;
}*/
module.exports = {
isJsonString,
checkIfRequestHasVote,
......
......@@ -238,19 +238,16 @@ client.on('data',function(data){
// 87.78.129.86 | localhost
const testClient = net.connect({host: 'localhost', port: 3000}, () => {
/*const testClient = net.connect({host: 'localhost', port: 3000}, () => {
console.log('connected to server!');
//testClient.write('Hello World Client!\r\n');
testClient.write(JSON.stringify({
"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"
//"vote": 80
}));
testClient.write(JSON.stringify({"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"}));
//test(testClient);
});
testClient.on('data', (data) => {
console.log(data.toString());
testClient.end();
//testClient.end();
});
/*testClient.on('end', () => {
console.log('disconnected from server');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment