From ccac73b5feb0f3fa92ecf219524e2415b1133256 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Lima <lgl15@inf.ufpr.br> Date: Mon, 3 Jul 2017 10:29:39 -0300 Subject: [PATCH] add group by to population query --- src/libs/routes/population.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/population.js b/src/libs/routes/population.js index 890f8c7e..18332fb8 100644 --- a/src/libs/routes/population.js +++ b/src/libs/routes/population.js @@ -89,16 +89,21 @@ rqf.addField({ populationApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { log.debug(req.sql.toParam()); - req.sql.field('(ibge_populacao.populacao)', 'populacao') + req.sql.field('ibge_populacao.populacao', 'population') .field('ibge_populacao.municipio_id', 'municipio_id') .field('ibge_populacao.ano_censo', 'year') .from('ibge_populacao') + .group('ibge_populacao.populacao') + .group('ibge_populacao.municipio_id') + .group('ibge_populacao.ano_censo') next(); }, query, (req, res, next) => { - let somapib = 0; - for (var i = 0; i < req.result.length; i++) { - req.result[i]; - } + // let somapop = 0; + // for (var i = 0; i < req.result.length; i++) { + // somapop += req.result[i].population; + // } + // + // req.result = [somapop]; next() }, id2str.transform(true), response('population')); -- GitLab