Skip to content

Commit 5820380

Browse files
ManethKulatungepierreTklein
authored andcommitted
feat: add batchAccept route to accept multiple hackers at once (#629)
* feat: Add HACKER_UPDATE_BATCH success message * feat: Add promise.allsettled so that we can wait for many promises to complete * feat: Add findByHackerId function to Account * feat: Add updatedHackerBatch controller function, generalize validation function, fix router * fix: resolve bug where requests hang when response is null * feat: set route apiVersion number to be 3.0.0 * feat: create parseAcceptBatch Co-authored-by: Pierre Theo Klein <pierre.klein@mail.mcgill.ca>
1 parent 940a54a commit 5820380

File tree

11 files changed

+623
-154
lines changed

11 files changed

+623
-154
lines changed

constants/routes.constant.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* ===***===***===***===***===***===***===***===***===
77
*
88
* If you are adding a route to this list, update this number
9-
* next avaiable createFromTime value: 165
9+
* next avaiable createFromTime value: 166
1010
*
1111
* If you are deleting a route from this list, please add the ID to the list of 'reserved' IDs,
1212
* so that we don't accidentally assign someone to a given ID.
@@ -178,6 +178,11 @@ const hackerRoutes = {
178178
uri: "/api/hacker/acceptEmail/" + Constants.ROLE_CATEGORIES.ALL,
179179
_id: mongoose.Types.ObjectId.createFromTime(130)
180180
},
181+
patchAcceptHackerByArrayOfIds: {
182+
requestType: Constants.REQUEST_TYPES.PATCH,
183+
uri: "/api/hacker/batchAccept",
184+
_id: mongoose.Types.ObjectId.createFromTime(165)
185+
},
181186
postAnySendWeekOfEmail: {
182187
requestType: Constants.REQUEST_TYPES.POST,
183188
uri: "/api/hacker/email/weekOf/" + Constants.ROLE_CATEGORIES.ALL,

constants/success.constant.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const HACKER_GET_BY_ID = "Hacker found by id.";
2121
const HACKER_READ = "Hacker retrieval successful.";
2222
const HACKER_CREATE = "Hacker creation successful.";
2323
const HACKER_UPDATE = "Hacker update successful.";
24+
const HACKER_UPDATE_BATCH = "Hacker batch update successful.";
2425
const HACKER_SENT_WEEK_OF = "Hacker week-of email sent.";
2526
const HACKER_SENT_DAY_OF = "Hacker day-of email sent.";
2627

@@ -76,6 +77,8 @@ module.exports = {
7677
HACKER_CREATE: HACKER_CREATE,
7778
HACKER_UPDATE: HACKER_UPDATE,
7879

80+
HACKER_UPDATE_BATCH: HACKER_UPDATE_BATCH,
81+
7982
HACKER_SENT_WEEK_OF: HACKER_SENT_WEEK_OF,
8083
HACKER_SENT_DAY_OF: HACKER_SENT_DAY_OF,
8184

controllers/hacker.controller.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,19 @@ function sentDayOfEmail(req, res) {
9292
});
9393
}
9494

95+
function updatedHackerBatch(req, res) {
96+
return res.status(200).json({
97+
message: Constants.Success.HACKER_UPDATE_BATCH,
98+
data: {
99+
success_ids: req.body.ids,
100+
errors: req.errors || []
101+
}
102+
});
103+
}
104+
95105
module.exports = {
96106
updatedHacker: updatedHacker,
107+
updatedHackerBatch: updatedHackerBatch,
97108
createdHacker: createdHacker,
98109
uploadedResume: uploadedResume,
99110
downloadedResume: downloadedResume,

0 commit comments

Comments
 (0)