Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Haakon Gunleiksrud
TDT4240_v20_haakon
Commits
7ebc49ee
Commit
7ebc49ee
authored
Apr 17, 2020
by
Tobias Ørstad
Browse files
final fixes to alerts
parent
9b9cc6a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/api/rounds.js
View file @
7ebc49ee
...
...
@@ -449,7 +449,7 @@ function roundcheck(client, tournament, roundid) {
// fetched the round objects of the active round
let
activePlayer
;
for
(
let
i
=
0
;
i
<
rounds
.
length
;
i
++
)
{
if
(
rounds
[
i
].
_id
.
str
==
roundid
.
str
)
{
if
(
String
(
rounds
[
i
].
_id
)
==
String
(
roundid
)
)
{
activePlayer
=
rounds
[
i
].
playerId
;
break
;
}
...
...
backend/api/tournament.js
View file @
7ebc49ee
...
...
@@ -309,6 +309,46 @@ router.get("/playeractive/:userid", (req, res) => {
);
});
router
.
get
(
"
/specific/:id
"
,
(
req
,
res
)
=>
{
MongoClient
.
connect
(
connectionUrl
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
(
err
,
client
)
=>
{
// Unable to connect to database
if
(
err
)
{
res
.
sendStatus
(
500
);
// Internal server error
return
;
}
let
id
;
if
(
!
req
.
params
.
id
)
{
res
.
sendStatus
(
400
);
}
try
{
id
=
mongo
.
ObjectID
(
req
.
params
.
id
);
}
catch
(
err
)
{
res
.
sendStatus
(
400
);
}
// Using the database gameWare and collection tournaments
const
db
=
client
.
db
(
"
gameWare
"
);
const
collection
=
"
tournaments
"
;
db
.
collection
(
collection
)
.
find
({
_id
:
id
,
})
.
toArray
((
err
,
result
)
=>
{
if
(
err
)
{
res
.
sendStatus
(
500
);
client
.
close
();
return
;
}
res
.
json
(
result
[
0
]);
client
.
close
();
});
}
);
});
router
.
get
(
"
/player/:userid/:active
"
,
(
req
,
res
)
=>
{
// Returns the tournaments of player with active field matching parameter
// Also checks the state of all tournaments
...
...
Write
Preview
Supports
Markdown
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