remove awardings simple parameter

pull/32/head
HardiReady 2018-03-25 20:33:13 +02:00
parent e284fffdee
commit dc0de2db89
1 changed files with 21 additions and 38 deletions

View File

@ -32,47 +32,30 @@ awarding.route('/')
if (req.query.inProgress) { if (req.query.inProgress) {
filter.confirmed = 0; filter.confirmed = 0;
} }
if (req.query.simple) { AwardingModel.find(filter, {}, {sort: {date: 'desc'}})
AwardingModel.find(filter, {}, {sort: {date: 'desc'}}, (err, items) => { .populate('decorationId').populate('proposer', resultSet)
if (err) { .exec((err, items) => {
err.status = codes.servererror; if (err) {
return next(err); err.status = codes.servererror;
// with return before (or after) the next(err) we prevent that the code continues here after next(err) return next(err);
// has finished. this saves an extra else {..} // with return before (or after) the next(err) we prevent that the code continues here
} // after next(err) has finished. this saves an extra else {..}
// if the collection is empty we do not send empty arrays back. }
if (items && items.length > 0) { let results = [];
res.locals.items = items; if (req.query.fractFilter) {
} for (let item of items) {
res.locals.processed = true; if (item.decorationId.fraction === req.query.fractFilter) {
next(); results.push(item);
});
} else {
AwardingModel.find(filter, {}, {sort: {date: 'desc'}})
.populate('decorationId').populate('proposer', resultSet)
.exec((err, items) => {
if (err) {
err.status = codes.servererror;
return next(err);
// with return before (or after) the next(err) we prevent that the code continues here
// after next(err) has finished. this saves an extra else {..}
}
let results = [];
if (req.query.fractFilter) {
for (let item of items) {
if (item.decorationId.fraction === req.query.fractFilter) {
results.push(item);
}
} }
res.locals.items = results;
} else {
res.locals.items = items;
} }
res.locals.items = results;
} else {
res.locals.items = items;
}
res.locals.processed = true; res.locals.processed = true;
next(); next();
}); });
}
}) })
.post(apiAuthenticationMiddleware, checkHl, (req, res, next) => { .post(apiAuthenticationMiddleware, checkHl, (req, res, next) => {