Add get squad unprocessed awardings apib tests; FIx lint
parent
a6b6677eb7
commit
8c27f1b454
|
@ -58,3 +58,15 @@ Create a new awarding proposal, that needs to be approved by higher permission l
|
|||
+ Response 201 (application/json; charset=utf-8)
|
||||
|
||||
+ Attributes (Awarding, fixed-type)
|
||||
|
||||
### Get Unprocessed Squad Awardings [GET /awardings/unprocessed/{squadId}]
|
||||
|
||||
List all awardings that are requested and in pending decision status
|
||||
|
||||
+ Parameters
|
||||
+ squadId: `5aba54eaeadcce6332c6a774` (string, required) - unique id of the squad in which awardings are requested
|
||||
|
||||
|
||||
+ Response 200 (application/json; charset=utf-8)
|
||||
|
||||
+ Attributes (array[AwardingPopulated], fixed-type)
|
||||
|
|
|
@ -83,19 +83,21 @@ awarding.route('/')
|
|||
|
||||
awarding.route('/unprocessed/:squadId')
|
||||
.get(apiAuthenticationMiddleware, checkSql, (req, res, next) => {
|
||||
console.log(req.params.squadId)
|
||||
const filter = {squadId: req.params.squadId};
|
||||
UserModel.find(filter, (err, users) => {
|
||||
if (!users || users.length === 0) {
|
||||
return next();
|
||||
}
|
||||
const squadUserIds = users.map(user => mongoose.Types.ObjectId(user._id));
|
||||
AwardingModel.find({userId: {$in: squadUserIds}, confirmed: 0}).populate('decorationId').populate('proposer', resultSet).populate('userId')
|
||||
const squadUserIds = users.map((user) => new mongoose.Types.ObjectId(user._id));
|
||||
AwardingModel.find({userId: {$in: squadUserIds}, confirmed: 0})
|
||||
.populate('decorationId')
|
||||
.populate('proposer', resultSet)
|
||||
.populate('userId')
|
||||
.exec((err, awards) => {
|
||||
res.locals.items = awards;
|
||||
next();
|
||||
});
|
||||
})
|
||||
res.locals.items = awards;
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
awarding.route('/:id')
|
||||
|
|
Loading…
Reference in New Issue