Skip to content

Commit

Permalink
created total requests per year endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
brodly committed Jul 27, 2019
1 parent 0811e63 commit aaf8800
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/javascript/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const config = year => {
}
};

const params = (requestType = 'Bulky Items') => {
const params = (requestType = 'Bulky Items', total = false) => {
return {
$select: ['zipcode', 'createddate', 'requesttype'],
$select: total ? ['count(requesttype)'] : ['createddate', 'zipcode', 'requesttype'],
$where: `requesttype="${requestType}"`,
$limit: 30,
};
Expand All @@ -40,5 +40,15 @@ app.get('/soda/:year/:requestType', (req, res) => {
});
})

app.get('/soda/:year/:requestType/total', (req, res) => {
const { year, requestType } = req.params;
const soda = newSoda(year);

soda.get(params(requestType, true), (err, response, data) => {
if (err) console.error(err);
else res.send(data);
})
});

app.listen(port, () => { console.log(`Listening on port: ${port}`)});

0 comments on commit aaf8800

Please sign in to comment.