From dc0de2db890e05dee246f7864311d37e9cf8d6aa Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 25 Mar 2018 20:33:13 +0200 Subject: [PATCH] remove awardings simple parameter --- api/routes/awardings.js | 59 +++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/api/routes/awardings.js b/api/routes/awardings.js index 7fbb84c..2402632 100644 --- a/api/routes/awardings.js +++ b/api/routes/awardings.js @@ -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) => {