Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progark gruppe 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ingebrigt Ørstad
Progark gruppe 3
Commits
8faf56b6
Commit
8faf56b6
authored
5 years ago
by
Tobias Ørstad
Browse files
Options
Downloads
Patches
Plain Diff
Allow fetching a users active tournaments. Issue
#4
parent
ef8c9ae5
No related branches found
No related tags found
2 merge requests
!20
Dev
,
!16
Resolve "Fetch tournament"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/api/tournament.js
+20
-28
20 additions, 28 deletions
backend/api/tournament.js
with
20 additions
and
28 deletions
backend/api/tournament.js
+
20
−
28
View file @
8faf56b6
...
...
@@ -3,8 +3,9 @@ const router = express.Router();
const
mongo
=
require
(
"
mongodb
"
);
const
MongoClient
=
mongo
.
MongoClient
;
const
connectionUrl
=
process
.
env
.
MONGO_CONNECTION_STRING
;
/*
router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
router
.
get
(
"
/playeractive/:userid
"
,
(
req
,
res
)
=>
{
// Connect to database
MongoClient
.
connect
(
connectionUrl
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
},
...
...
@@ -15,37 +16,28 @@ router.post("/new/:host/:games/:name/:tpr/:players/:rpg", (req, res) => {
return
;
}
const games = req.params.games.split("&");
// Using the database gameWare and collection tournaments
const
db
=
client
.
db
(
"
gameWare
"
);
const
collection
=
"
tournaments
"
;
const tournamentid;
db.collection(collection).insertOne(
{
gameid: req.body.gameid,
players: [req.body.userid],
games: "todo",
name: req.body.name,
timePerRound: parseInt(req.body.timePerRound),
maxPlayers: parseInt(req.body.maxPlayers),
roundsPerGame: parseInt(req.body.roundsPerGame),
currentRound: 1,
dateCreated: new Date()
},
(err, result) => {
const
id
=
mongo
.
ObjectId
(
req
.
params
.
userid
);
db
.
collection
(
collection
)
.
find
({
_id
:
id
,
active
:
true
})
.
toArray
((
err
,
result
)
=>
{
if
(
err
)
{
res.sendStatus(500); // Internal server error
res
.
sendStatus
(
500
);
//console.log(err);
return
;
}
tournamentid = result._id;
res
.
json
(
result
);
});
}
);
db.collection("rounds").insertOne(
{
});
}
)
}
);
});*/
// Export API routes
module
.
exports
=
router
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment