Skip to content

Commit

Permalink
Add teamId to expansion of query result, and keep team member ids in … (
Browse files Browse the repository at this point in the history
#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()
  • Loading branch information
pierreTklein authored Jan 22, 2019
1 parent 9f9012a commit 24bf4c5
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 96 deletions.
1 change: 0 additions & 1 deletion controllers/team.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Constants = {
*/
function showTeam(req, res) {
const teamData = req.body.team.toJSON();
delete teamData.members;

const memberNames = [];
for (const member of req.body.teamMembers) {
Expand Down
18 changes: 9 additions & 9 deletions docs/api/api_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ define({
},
{
"type": "get",
"url": "/hacker/email/:email",
"url": "/hacker/:id",
"title": "get a hacker's information",
"name": "getHacker",
"group": "Hacker",
Expand All @@ -1268,8 +1268,8 @@ define({
"group": "param",
"type": "String",
"optional": false,
"field": "email",
"description": "<p>a hacker's unique email</p>"
"field": "id",
"description": "<p>a hacker's unique mongoID</p>"
}]
}
},
Expand Down Expand Up @@ -1324,12 +1324,12 @@ define({
"filename": "routes/api/hacker.js",
"groupTitle": "Hacker",
"sampleRequest": [{
"url": "https://api.mchacks.ca/api/hacker/email/:email"
"url": "https://api.mchacks.ca/api/hacker/:id"
}]
},
{
"type": "get",
"url": "/hacker/:id",
"url": "/hacker/email/:email",
"title": "get a hacker's information",
"name": "getHacker",
"group": "Hacker",
Expand All @@ -1340,8 +1340,8 @@ define({
"group": "param",
"type": "String",
"optional": false,
"field": "id",
"description": "<p>a hacker's unique mongoID</p>"
"field": "email",
"description": "<p>a hacker's unique email</p>"
}]
}
},
Expand Down Expand Up @@ -1396,7 +1396,7 @@ define({
"filename": "routes/api/hacker.js",
"groupTitle": "Hacker",
"sampleRequest": [{
"url": "https://api.mchacks.ca/api/hacker/:id"
"url": "https://api.mchacks.ca/api/hacker/email/:email"
}]
},
{
Expand Down Expand Up @@ -2645,7 +2645,7 @@ define({
},
"examples": [{
"title": "Success-Response: ",
"content": "{\n \"message\": \"Successfully retrieved team information\", \n \"data\": {...}\n }",
"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 }",
"type": "object"
}]
},
Expand Down
18 changes: 9 additions & 9 deletions docs/api/api_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@
},
{
"type": "get",
"url": "/hacker/email/:email",
"url": "/hacker/:id",
"title": "get a hacker's information",
"name": "getHacker",
"group": "Hacker",
Expand All @@ -1267,8 +1267,8 @@
"group": "param",
"type": "String",
"optional": false,
"field": "email",
"description": "<p>a hacker's unique email</p>"
"field": "id",
"description": "<p>a hacker's unique mongoID</p>"
}]
}
},
Expand Down Expand Up @@ -1323,12 +1323,12 @@
"filename": "routes/api/hacker.js",
"groupTitle": "Hacker",
"sampleRequest": [{
"url": "https://api.mchacks.ca/api/hacker/email/:email"
"url": "https://api.mchacks.ca/api/hacker/:id"
}]
},
{
"type": "get",
"url": "/hacker/:id",
"url": "/hacker/email/:email",
"title": "get a hacker's information",
"name": "getHacker",
"group": "Hacker",
Expand All @@ -1339,8 +1339,8 @@
"group": "param",
"type": "String",
"optional": false,
"field": "id",
"description": "<p>a hacker's unique mongoID</p>"
"field": "email",
"description": "<p>a hacker's unique email</p>"
}]
}
},
Expand Down Expand Up @@ -1395,7 +1395,7 @@
"filename": "routes/api/hacker.js",
"groupTitle": "Hacker",
"sampleRequest": [{
"url": "https://api.mchacks.ca/api/hacker/:id"
"url": "https://api.mchacks.ca/api/hacker/email/:email"
}]
},
{
Expand Down Expand Up @@ -2643,7 +2643,7 @@
},
"examples": [{
"title": "Success-Response: ",
"content": "{\n \"message\": \"Successfully retrieved team information\", \n \"data\": {...}\n }",
"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 }",
"type": "object"
}]
},
Expand Down
30 changes: 15 additions & 15 deletions docs/api/api_project.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
define({
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-21T04:13:36.482Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
define({
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-21T04:13:36.482Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
30 changes: 15 additions & 15 deletions docs/api/api_project.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-21T04:13:36.482Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
{
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-01-21T04:13:36.482Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
5 changes: 3 additions & 2 deletions middlewares/team.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,14 @@ async function populateMemberAccountsById(req, res, next) {
data: {}
});
}

let hackerIds = [];
let teamMembers = [];

for (const member of team.members) {
teamMembers.push(member.accountId);
hackerIds.push(member._id);
}

team.members = hackerIds;
req.body.team = team;
req.body.teamMembers = teamMembers;
return next();
Expand Down
Loading

0 comments on commit 24bf4c5

Please sign in to comment.