Skip to content

Commit 24bf4c5

Browse files
authored
Add teamId to expansion of query result, and keep team member ids in … (#300)
* Add teamId to expansion of query result, and keep team member ids in get team * Update test * Update comments * doc updates * Bug fix * ObjectId object -> string * accountId -> hackerId * _id -> .toString()
1 parent 9f9012a commit 24bf4c5

File tree

11 files changed

+100
-96
lines changed

11 files changed

+100
-96
lines changed

controllers/team.controller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const Constants = {
2020
*/
2121
function showTeam(req, res) {
2222
const teamData = req.body.team.toJSON();
23-
delete teamData.members;
2423

2524
const memberNames = [];
2625
for (const member of req.body.teamMembers) {

docs/api/api_data.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ define({
12571257
},
12581258
{
12591259
"type": "get",
1260-
"url": "/hacker/email/:email",
1260+
"url": "/hacker/:id",
12611261
"title": "get a hacker's information",
12621262
"name": "getHacker",
12631263
"group": "Hacker",
@@ -1268,8 +1268,8 @@ define({
12681268
"group": "param",
12691269
"type": "String",
12701270
"optional": false,
1271-
"field": "email",
1272-
"description": "<p>a hacker's unique email</p>"
1271+
"field": "id",
1272+
"description": "<p>a hacker's unique mongoID</p>"
12731273
}]
12741274
}
12751275
},
@@ -1324,12 +1324,12 @@ define({
13241324
"filename": "routes/api/hacker.js",
13251325
"groupTitle": "Hacker",
13261326
"sampleRequest": [{
1327-
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1327+
"url": "https://api.mchacks.ca/api/hacker/:id"
13281328
}]
13291329
},
13301330
{
13311331
"type": "get",
1332-
"url": "/hacker/:id",
1332+
"url": "/hacker/email/:email",
13331333
"title": "get a hacker's information",
13341334
"name": "getHacker",
13351335
"group": "Hacker",
@@ -1340,8 +1340,8 @@ define({
13401340
"group": "param",
13411341
"type": "String",
13421342
"optional": false,
1343-
"field": "id",
1344-
"description": "<p>a hacker's unique mongoID</p>"
1343+
"field": "email",
1344+
"description": "<p>a hacker's unique email</p>"
13451345
}]
13461346
}
13471347
},
@@ -1396,7 +1396,7 @@ define({
13961396
"filename": "routes/api/hacker.js",
13971397
"groupTitle": "Hacker",
13981398
"sampleRequest": [{
1399-
"url": "https://api.mchacks.ca/api/hacker/:id"
1399+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
14001400
}]
14011401
},
14021402
{
@@ -2645,7 +2645,7 @@ define({
26452645
},
26462646
"examples": [{
26472647
"title": "Success-Response: ",
2648-
"content": "{\n \"message\": \"Successfully retrieved team information\", \n \"data\": {...}\n }",
2648+
"content": "{\n \"message\": \"Team retrieval successful\", \n \"data\": { \n \"team\": {\n \"name\":\"foo\",\n \"members\": [\n ObjectId('...')\n ],\n \"devpostURL\": \"www.devpost.com/foo\",\n \"projectName\": \"fooey\"\n },\n \"members\": [\n {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n }\n ],\n }\n }",
26492649
"type": "object"
26502650
}]
26512651
},

docs/api/api_data.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@
12561256
},
12571257
{
12581258
"type": "get",
1259-
"url": "/hacker/email/:email",
1259+
"url": "/hacker/:id",
12601260
"title": "get a hacker's information",
12611261
"name": "getHacker",
12621262
"group": "Hacker",
@@ -1267,8 +1267,8 @@
12671267
"group": "param",
12681268
"type": "String",
12691269
"optional": false,
1270-
"field": "email",
1271-
"description": "<p>a hacker's unique email</p>"
1270+
"field": "id",
1271+
"description": "<p>a hacker's unique mongoID</p>"
12721272
}]
12731273
}
12741274
},
@@ -1323,12 +1323,12 @@
13231323
"filename": "routes/api/hacker.js",
13241324
"groupTitle": "Hacker",
13251325
"sampleRequest": [{
1326-
"url": "https://api.mchacks.ca/api/hacker/email/:email"
1326+
"url": "https://api.mchacks.ca/api/hacker/:id"
13271327
}]
13281328
},
13291329
{
13301330
"type": "get",
1331-
"url": "/hacker/:id",
1331+
"url": "/hacker/email/:email",
13321332
"title": "get a hacker's information",
13331333
"name": "getHacker",
13341334
"group": "Hacker",
@@ -1339,8 +1339,8 @@
13391339
"group": "param",
13401340
"type": "String",
13411341
"optional": false,
1342-
"field": "id",
1343-
"description": "<p>a hacker's unique mongoID</p>"
1342+
"field": "email",
1343+
"description": "<p>a hacker's unique email</p>"
13441344
}]
13451345
}
13461346
},
@@ -1395,7 +1395,7 @@
13951395
"filename": "routes/api/hacker.js",
13961396
"groupTitle": "Hacker",
13971397
"sampleRequest": [{
1398-
"url": "https://api.mchacks.ca/api/hacker/:id"
1398+
"url": "https://api.mchacks.ca/api/hacker/email/:email"
13991399
}]
14001400
},
14011401
{
@@ -2643,7 +2643,7 @@
26432643
},
26442644
"examples": [{
26452645
"title": "Success-Response: ",
2646-
"content": "{\n \"message\": \"Successfully retrieved team information\", \n \"data\": {...}\n }",
2646+
"content": "{\n \"message\": \"Team retrieval successful\", \n \"data\": { \n \"team\": {\n \"name\":\"foo\",\n \"members\": [\n ObjectId('...')\n ],\n \"devpostURL\": \"www.devpost.com/foo\",\n \"projectName\": \"fooey\"\n },\n \"members\": [\n {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n }\n ],\n }\n }",
26472647
"type": "object"
26482648
}]
26492649
},

docs/api/api_project.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
define({
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-21T04:13:36.482Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
define({
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-21T04:13:36.482Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
});

docs/api/api_project.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{
2-
"name": "hackerAPI",
3-
"version": "0.0.8",
4-
"description": "Documentation for the API used for mchacks",
5-
"defaultVersion": "0.0.8",
6-
"title": "hackerAPI documentation",
7-
"url": "https://api.mchacks.ca/api",
8-
"sampleUrl": "https://api.mchacks.ca/api",
9-
"apidoc": "0.3.0",
10-
"generator": {
11-
"name": "apidoc",
12-
"time": "2019-01-21T04:13:36.482Z",
13-
"url": "http://apidocjs.com",
14-
"version": "0.17.7"
15-
}
1+
{
2+
"name": "hackerAPI",
3+
"version": "0.0.8",
4+
"description": "Documentation for the API used for mchacks",
5+
"defaultVersion": "0.0.8",
6+
"title": "hackerAPI documentation",
7+
"url": "https://api.mchacks.ca/api",
8+
"sampleUrl": "https://api.mchacks.ca/api",
9+
"apidoc": "0.3.0",
10+
"generator": {
11+
"name": "apidoc",
12+
"time": "2019-01-21T04:13:36.482Z",
13+
"url": "http://apidocjs.com",
14+
"version": "0.17.7"
15+
}
1616
}

middlewares/team.middleware.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,14 @@ async function populateMemberAccountsById(req, res, next) {
407407
data: {}
408408
});
409409
}
410-
410+
let hackerIds = [];
411411
let teamMembers = [];
412412

413413
for (const member of team.members) {
414414
teamMembers.push(member.accountId);
415+
hackerIds.push(member._id);
415416
}
416-
417+
team.members = hackerIds;
417418
req.body.team = team;
418419
req.body.teamMembers = teamMembers;
419420
return next();

0 commit comments

Comments
 (0)