diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d5f3e1bb1cef9c3bdd7380b90f1de2ef9e57d9d..db6054bea9e0b5f1fab5d99f4889d8f9830f8a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added * Out of school population indicator +## 1.0.2 - 2018-04-18 +### Changed +- Fixed bug in pibpercapita route + ## 1.0.1 - 2018-03-15 ### Changed - Fix missing school id in teacher and class routes diff --git a/src/libs/routes/pibpercapita.js b/src/libs/routes/pibpercapita.js index 10e03b0fa17bb497fe55c1552696411aa1d78302..57b7089837579d9d1aa2d51a0a8c81591026d699 100644 --- a/src/libs/routes/pibpercapita.js +++ b/src/libs/routes/pibpercapita.js @@ -86,8 +86,8 @@ rqf.addField({ }).addValue({ name: 'state', table: 'estado', - tableField: 'nome', - resultField: 'state_name', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], where: { relation: '=', type: 'integer', @@ -163,21 +163,23 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .order('ibge_pib.ano_censo') } next(); -}, query, addMissing(rqf), id2str.transform(false), (req, res, next) => { +}, query, (req, res, next) => { req.result.forEach((i) => { - let value = i.total; - let res = value.toString().split("."); - //rounding decimal. - let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3)); - //case 0 after comma - if (res[1].toString().substring(0,1) == 0) { - i.total = parseFloat(res[0] + "." + "0" + decimal); - } else { - i.total = parseFloat(res[0] + "." + decimal); - } + let value = i.total; + console.log(i.total); + let res = value.toString().split("."); + //rounding decimal. + let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3)); + //case 0 after comma + if (res[1].toString().substring(0,1) == 0) { + i.total = parseFloat(res[0] + "." + "0" + decimal); + } else { + i.total = parseFloat(res[0] + "." + decimal); + } + console.log(i.total); }); next(); - }, response("pibpercapita")); + }, addMissing(rqf), id2str.transform(false), response("pibpercapita")); module.exports = pibpercapitaApp;