Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting
Commits
65845954
Commit
65845954
authored
Aug 21, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Vote Update Bug
parent
238b8299
Pipeline
#430
passed with stages
in 2 minutes and 43 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
events.js
events.js
+1
-2
helpFunctions.js
helpFunctions.js
+4
-0
socket.js
socket.js
+3
-6
No files found.
events.js
View file @
65845954
...
@@ -33,7 +33,6 @@ function createRouter(db) {
...
@@ -33,7 +33,6 @@ function createRouter(db) {
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in hasMap
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
error in hasMap
'
});
}
else
{
}
else
{
numberResults
=
results
[
0
].
Maps
;
numberResults
=
results
[
0
].
Maps
;
console
.
log
(
numberResults
);
if
(
numberResults
===
1
)
next
();
if
(
numberResults
===
1
)
next
();
else
if
(
numberResults
===
0
)
addMap
(
req
,
res
,
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
'
});
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) {
...
@@ -113,7 +112,7 @@ function createRouter(db) {
const
userId
=
req
.
body
.
userId
;
const
userId
=
req
.
body
.
userId
;
const
mapId
=
req
.
body
.
mapId
;
const
mapId
=
req
.
body
.
mapId
;
const
vote
=
req
.
body
.
vote
;
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
);
console
.
log
(
'
Update Vote:
'
,
sql
);
db
.
query
(
db
.
query
(
sql
,
sql
,
...
...
helpFunctions.js
View file @
65845954
...
@@ -31,6 +31,10 @@ function sendRequest(url, json, callback) {
...
@@ -31,6 +31,10 @@ function sendRequest(url, json, callback) {
});
});
}
}
/*function addMapToClient(clintList, client, mapId) {
const clientId = client.name;
}*/
module
.
exports
=
{
module
.
exports
=
{
isJsonString
,
isJsonString
,
checkIfRequestHasVote
,
checkIfRequestHasVote
,
...
...
socket.js
View file @
65845954
...
@@ -238,19 +238,16 @@ client.on('data',function(data){
...
@@ -238,19 +238,16 @@ client.on('data',function(data){
// 87.78.129.86 | localhost
// 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!');
console.log('connected to server!');
//testClient.write('Hello World Client!\r\n');
//testClient.write('Hello World Client!\r\n');
testClient
.
write
(
JSON
.
stringify
({
testClient.write(JSON.stringify({"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"}));
"
mapId
"
:
"
7fsfRSUCQ7YwfBEdRk_GivW6qzj
"
,
"
userId
"
:
"
aKBNg9fbReqLedLiz1KFfA
"
,
"
name
"
:
"
Summer 2021 - 01
"
//"vote": 80
}));
//test(testClient);
//test(testClient);
});
});
testClient.on('data', (data) => {
testClient.on('data', (data) => {
console.log(data.toString());
console.log(data.toString());
testClient
.
end
();
//
testClient.end();
});
});
/*testClient.on('end', () => {
/*testClient.on('end', () => {
console.log('disconnected from server');
console.log('disconnected from server');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment