diff --git a/src/api/routes/reports/index.js b/src/api/routes/reports/index.js index ba05069..1ac810a 100644 --- a/src/api/routes/reports/index.js +++ b/src/api/routes/reports/index.js @@ -23,7 +23,7 @@ export default ({ config, db, logger }) => { geoformat: Joi.any().valid(config.GEO_FORMATS).default(config.GEO_FORMAT_DEFAULT) } }), - (req, res, next) => reports(config, db, logger).all(req.query.city,req.query.timeperiod) + (req, res, next) => reports(config, db, logger).all(req.query.timeperiod, req.query.city) .then((data) => handleGeoResponse(data, req, res, next)) .catch((err) => { logger.error(err); diff --git a/src/api/routes/reports/model.js b/src/api/routes/reports/model.js index 91c211b..34308ad 100644 --- a/src/api/routes/reports/model.js +++ b/src/api/routes/reports/model.js @@ -2,9 +2,12 @@ import Promise from 'bluebird'; export default (config, db, logger) => ({ - // Return all reports within the defined max period - // Optional: city (Petabencana.id Instance Region 3 letter code) - all: (city,timeperiod) => new Promise((resolve, reject) => { + /** + * Return all reports within a defined time period, and optionally city + * @param {integer} timeperiod Length of time period in seconds + * @param {string} city Optional, instance region code (e.g. 'jbd') + */ + all: (timeperiod, city) => new Promise((resolve, reject) => { // Setup query let query = `SELECT pkey, created_at, source,