Skip to content
Snippets Groups Projects
Commit cc90a644 authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Fix Pib per capita route

parent 8151d10b
No related branches found
No related tags found
1 merge request!155Release v1.7.0
Pipeline #17537 failed
...@@ -155,6 +155,7 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -155,6 +155,7 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('ibge_pib.ano_censo') .group('ibge_pib.ano_censo')
.group('ibge_pib.pib_per_capita') .group('ibge_pib.pib_per_capita')
.order('ibge_pib.ano_censo') .order('ibge_pib.ano_censo')
console.log("CiTy")
} else { } else {
req.sql.from('ibge_pib') req.sql.from('ibge_pib')
.field('SUM(ibge_pib.pib)/SUM(ibge_pib.populacao)', 'total') .field('SUM(ibge_pib.pib)/SUM(ibge_pib.populacao)', 'total')
...@@ -165,8 +166,14 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -165,8 +166,14 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
next(); next();
}, query, (req, res, next) => { }, query, (req, res, next) => {
req.result.forEach((i) => { req.result.forEach((i) => {
let value = i.total; let value = parseFloat(i.total);
let isnum = /^\d+$/.test(value);
if (isnum == true) {
value = value.toFixed(2)
console.log(value)
}
// console.log(i.total); // console.log(i.total);
let res = value.toString().split("."); let res = value.toString().split(".");
//rounding decimal. //rounding decimal.
let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3)); let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment