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
354ed5c0
Commit
354ed5c0
authored
Aug 23, 2021
by
Matthieu - Greep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove error if no votes
parent
11beaeeb
Pipeline
#451
passed with stage
in 1 minute and 13 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
getPlayerVote.js
route/getPlayerVote.js
+18
-3
getVotes.js
route/getVotes.js
+6
-1
No files found.
route/getPlayerVote.js
View file @
354ed5c0
...
@@ -21,13 +21,28 @@ module.exports = function(app, sql, token, errorHandler) {
...
@@ -21,13 +21,28 @@ module.exports = function(app, sql, token, errorHandler) {
errorHandler
(
res
,
500
,
'
Internal server error
'
);
errorHandler
(
res
,
500
,
'
Internal server error
'
);
}
else
{
}
else
{
if
(
sqlRes
.
length
===
0
)
{
if
(
sqlRes
.
length
===
0
)
{
return
errorHandler
(
res
,
404
,
'
No vote found
'
);
return
res
.
json
({
mapUid
:
mapId
,
playerLogin
:
player
,
vote
:
-
1
,
date
:
""
});
}
}
if
(
sqlRes
[
0
].
map
==
null
)
{
if
(
sqlRes
[
0
].
map
==
null
)
{
return
errorHandler
(
res
,
404
,
'
Map not found
'
);
return
res
.
json
({
mapUid
:
mapId
,
playerLogin
:
player
,
vote
:
-
1
,
date
:
""
});
}
}
if
(
sqlRes
[
0
].
player
==
null
)
{
if
(
sqlRes
[
0
].
player
==
null
)
{
return
errorHandler
(
res
,
404
,
'
Player not found
'
);
return
res
.
json
({
mapUid
:
mapId
,
playerLogin
:
player
,
vote
:
-
1
,
date
:
""
});
}
}
res
.
json
({
res
.
json
({
...
...
route/getVotes.js
View file @
354ed5c0
...
@@ -17,7 +17,12 @@ module.exports = function(app, sql, token, errorHandler) {
...
@@ -17,7 +17,12 @@ module.exports = function(app, sql, token, errorHandler) {
errorHandler
(
res
,
500
,
'
Internal server error
'
);
errorHandler
(
res
,
500
,
'
Internal server error
'
);
}
else
{
}
else
{
if
(
sqlRes
[
0
].
map
==
null
)
{
if
(
sqlRes
[
0
].
map
==
null
)
{
return
errorHandler
(
res
,
404
,
'
Map not found
'
);
return
res
.
json
({
mapUid
:
mapId
,
votes
:
0
,
average
:
0
,
lastVoteDate
:
""
});
}
}
// Get the latest date from an array
// Get the latest date from an array
const
latestDate
=
new
Date
(
Math
.
max
.
apply
(
null
,
sqlRes
.
map
(
function
(
e
)
{
const
latestDate
=
new
Date
(
Math
.
max
.
apply
(
null
,
sqlRes
.
map
(
function
(
e
)
{
...
...
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