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) {
filter.confirmed = 0;
}
if (req.query.simple) {
AwardingModel.find(filter, {}, {sort: {date: 'desc'}}, (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 {..}
}
// if the collection is empty we do not send empty arrays back.
if (items && items.length > 0) {
res.locals.items = items;
}
res.locals.processed = true;
next();
});
} 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);
}
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;
next();
});
}
res.locals.processed = true;
next();
});
})
.post(apiAuthenticationMiddleware, checkHl, (req, res, next) => {