Skip to content
Snippets Groups Projects
Commit d05b1c49 authored by Tobias Ingebrigt Ørstad's avatar Tobias Ingebrigt Ørstad
Browse files

Merge branch '95-backend-cleanup' into 'dev'

final fixes to alerts

Closes #95

See merge request tobiasio/progark-gruppe-3!101
parents 533ff1e0 7ebc49ee
No related branches found
No related tags found
1 merge request!101final fixes to alerts
......@@ -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;
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment