From eed07b4629616e14eba2bb08747fb83c652bdc0a Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Thu, 20 Sep 2018 10:30:25 -0300 Subject: [PATCH 1/4] Add route pib/transport --- src/libs/routes/pibpercapita.js | 9 ++++++++- src/libs/routes/transport.js | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/libs/routes/pibpercapita.js b/src/libs/routes/pibpercapita.js index bfe2c4dd..aacebe6e 100644 --- a/src/libs/routes/pibpercapita.js +++ b/src/libs/routes/pibpercapita.js @@ -155,6 +155,7 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .group('ibge_pib.ano_censo') .group('ibge_pib.pib_per_capita') .order('ibge_pib.ano_censo') + console.log("CiTy") } else { req.sql.from('ibge_pib') .field('SUM(ibge_pib.pib)/SUM(ibge_pib.populacao)', 'total') @@ -165,8 +166,14 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { next(); }, query, (req, res, next) => { 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); + let res = value.toString().split("."); //rounding decimal. let decimal = Math.round(res[1].toString().substring(0,2) + (".") + res[1].toString().substring(2,3)); diff --git a/src/libs/routes/transport.js b/src/libs/routes/transport.js index 266b1400..449895d0 100644 --- a/src/libs/routes/transport.js +++ b/src/libs/routes/transport.js @@ -373,14 +373,14 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { // Vans e Kombi let goVansAndKombi = allTransports.clone(); goVansAndKombi.field('matricula.transporte_vans_kombi','use_transport_id') - goVansAndKombi.where('matricula.transporte_vans_kombi = 1 OR matricula.transporte_vans_kombi = 0'); + goVansAndKombi.where('matricula.transporte_vans_kombi = 1'); goVansAndKombi.group('matricula.transporte_vans_kombi'); req.queryIndex.goVansAndKombi = req.querySet.push(goVansAndKombi) - 1; // Micro let goMicroBus = allTransports.clone(); goMicroBus.field('matricula.transporte_micro_onibus', 'use_transport_id') - goMicroBus.where('matricula.transporte_micro_onibus = 1 OR matricula.transporte_micro_onibus = 0'); + goMicroBus.where('matricula.transporte_micro_onibus = 1'); goMicroBus.group('matricula.transporte_micro_onibus'); req.queryIndex.goMicroBus = req.querySet.push(goMicroBus) - 1; @@ -388,63 +388,63 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { // Ônibus let goBus = allTransports.clone(); goBus.field("matricula.transporte_onibus", 'use_transport_id') - goBus.where('matricula.transporte_onibus = 1 OR matricula.transporte_onibus = 0'); + goBus.where('matricula.transporte_onibus = 1'); goBus.group('matricula.transporte_onibus') req.queryIndex.goBus = req.querySet.push(goBus) - 1; // Bicicleta let goBikes = allTransports.clone(); goBikes.field('matricula.transporte_bicicleta', 'use_transport_id') - goBikes.where('matricula.transporte_bicicleta = 1 OR matricula.transporte_bicicleta = 0'); + goBikes.where('matricula.transporte_bicicleta = 1'); goBikes.group('matricula.transporte_bicicleta') req.queryIndex.goBikes = req.querySet.push(goBikes) - 1; // Tração Animal let goAnimalTraction = allTransports.clone(); goAnimalTraction.field('matricula.transporte_animal', 'use_transport_id') - goAnimalTraction.where('matricula.transporte_animal = 1 OR matricula.transporte_animal = 0'); + goAnimalTraction.where('matricula.transporte_animal = 1'); goAnimalTraction.group('matricula.transporte_animal') req.queryIndex.goAnimalTraction = req.querySet.push(goAnimalTraction) - 1; // Outro Veículo let goOtherVehicle = allTransports.clone(); goOtherVehicle.field('matricula.transporte_outro', 'use_transport_id') - goOtherVehicle.where('matricula.transporte_outro = 1 OR matricula.transporte_outro = 0'); + goOtherVehicle.where('matricula.transporte_outro = 1'); goOtherVehicle.group('matricula.transporte_outro') req.queryIndex.goOtherVehicle = req.querySet.push(goOtherVehicle) - 1; // Aquaviário/ Embarcação (capacidade até 5 alunos) let goWaterway_5_Students = allTransports.clone(); goWaterway_5_Students.field('matricula.transporte_embar_0_5','use_transport_id') - goWaterway_5_Students.where('matricula.transporte_embar_0_5 = 1 OR matricula.transporte_embar_0_5 = 0'); + goWaterway_5_Students.where('matricula.transporte_embar_0_5 = 1'); goWaterway_5_Students.group('matricula.transporte_embar_0_5') req.queryIndex.goWaterway_5_Students = req.querySet.push(goWaterway_5_Students) - 1; // Aquaviário/ Embarcação (capacidade de 5 até 15 alunos) let goWaterway_15_Students = allTransports.clone(); goWaterway_15_Students.field('matricula.transporte_embar_5_15', 'use_transport_id') - goWaterway_15_Students.where('matricula.transporte_embar_5_15 = 1 OR matricula.transporte_embar_5_15 = 0'); + goWaterway_15_Students.where('matricula.transporte_embar_5_15 = 1'); goWaterway_15_Students.group('matricula.transporte_embar_5_15') req.queryIndex.goWaterway_15_Students = req.querySet.push(goWaterway_15_Students) - 1; // Aquaviário/ Embarcação (capacidade de 15 até 35 alunos)r let goWaterway_35_Students = allTransports.clone(); goWaterway_35_Students.field('matricula.transporte_embar_15_35', 'use_transport_id') - goWaterway_35_Students.where('matricula.transporte_embar_15_35 = 1 OR matricula.transporte_embar_15_35 = 0'); + goWaterway_35_Students.where('matricula.transporte_embar_15_35 = 1'); goWaterway_35_Students.group('matricula.transporte_embar_15_35') req.queryIndex.goWaterway_35_Students = req.querySet.push(goWaterway_35_Students) - 1; // Aquaviário/ Embarcação (capacidade mais 35 alunos) let goWaterwayMoreThan_35 = allTransports.clone(); goWaterwayMoreThan_35.field('matricula.transporte_embar_35', 'use_transport_id') - goWaterwayMoreThan_35.where('matricula.transporte_embar_35 = 1 OR matricula.transporte_embar_35 = 0'); + goWaterwayMoreThan_35.where('matricula.transporte_embar_35 = 1'); goWaterwayMoreThan_35.group('matricula.transporte_embar_35') req.queryIndex.goWaterwayMoreThan_35 = req.querySet.push(goWaterwayMoreThan_35) - 1; // Trêm / Metrô let goSubwayAndTrain = allTransports.clone(); goSubwayAndTrain.field('matricula.transporte_trem_metro', 'use_transport_id') - goSubwayAndTrain.where('matricula.transporte_trem_metro = 1 OR matricula.transporte_trem_metro = 0'); + goSubwayAndTrain.where('matricula.transporte_trem_metro = 1'); goSubwayAndTrain.group('matricula.transporte_trem_metro') req.queryIndex.goSubwayAndTrain = req.querySet.push(goSubwayAndTrain) - 1; @@ -463,8 +463,8 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { for (let i = 0; i < transport_match_0.length; i++) { transport_match_0[i].use_transport_id = true; transport_match.push(transport_match_0[i]) - transport_match_1[i].use_transport_id = false; - transport_match.push(transport_match_1[i]) + // transport_match_1[i].use_transport_id = false; + // transport_match.push(transport_match_1[i]) } //modifica adicionando use_transport_id=false, com os mesmos valores @@ -472,8 +472,8 @@ transportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { for (let i = 0; i < all_enrollment_match_0.length; i++) { all_enrollment_match_0[i].use_transport_id = true; all_enrollment_match.push(all_enrollment_match_0[i]) - all_enrollment_match_1[i].use_transport_id = false; - all_enrollment_match.push(all_enrollment_match_1[i]) + // all_enrollment_match_1[i].use_transport_id = false; + // all_enrollment_match.push(all_enrollment_match_1[i]) } let public_transport = matchQueries(all_enrollment_match, req.result[req.queryIndex.allEnrollmentTransport]); -- GitLab From 300e4aec2216ba03a24bca05769d1ee3318433d0 Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Thu, 20 Sep 2018 10:31:34 -0300 Subject: [PATCH 2/4] Remove logs --- src/libs/routes/pibpercapita.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/routes/pibpercapita.js b/src/libs/routes/pibpercapita.js index aacebe6e..59a74eaf 100644 --- a/src/libs/routes/pibpercapita.js +++ b/src/libs/routes/pibpercapita.js @@ -155,7 +155,6 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .group('ibge_pib.ano_censo') .group('ibge_pib.pib_per_capita') .order('ibge_pib.ano_censo') - console.log("CiTy") } else { req.sql.from('ibge_pib') .field('SUM(ibge_pib.pib)/SUM(ibge_pib.populacao)', 'total') @@ -170,7 +169,6 @@ pibpercapitaApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { let isnum = /^\d+$/.test(value); if (isnum == true) { value = value.toFixed(2) - console.log(value) } // console.log(i.total); -- GitLab From dcdf16631baa3b6dd7579f893bd5222160c3a88b Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Thu, 20 Sep 2018 10:33:43 -0300 Subject: [PATCH 3/4] Change population filter name --- src/libs/convert/citySize.js | 2 +- src/libs/routes/infrastructure.js | 25 ++++++++++++++++--------- src/libs/routes/population.js | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/libs/convert/citySize.js b/src/libs/convert/citySize.js index 819eb150..3f50462b 100644 --- a/src/libs/convert/citySize.js +++ b/src/libs/convert/citySize.js @@ -1,7 +1,7 @@ module.exports = function citySize(id) { switch (id) { case 1: - return 'até 5000'; + return '0 - 5000'; case 2: return '5001 - 10000'; case 3: diff --git a/src/libs/routes/infrastructure.js b/src/libs/routes/infrastructure.js index 290bf1a0..8b01e338 100644 --- a/src/libs/routes/infrastructure.js +++ b/src/libs/routes/infrastructure.js @@ -67,19 +67,26 @@ infrastructureApp.get('/rural_location', (req, res, next) => { }, response('rural_location')); infrastructureApp.get('/adm_dependency', (req, res, next) => { - req.sql.from('dependencia_adm') - .field('id') - .field('nome', 'name') - .where('id <= 4'); + req.result = []; + for(let i = 1; i <= 4; ++i) { + req.result.push({ + id: i, + name: id2str.admDependency(i) + }); + }; next(); -}, query, response('adm_dependency')); +}, response('adm_dependency')); infrastructureApp.get('/adm_dependency_detailed', (req, res, next) => { - req.sql.from('dependencia_adm_priv') - .field('id', 'id') - .field('nome', 'name'); + req.result = []; + for(let i = 1; i <= 6; ++i) { + req.result.push({ + id: i, + name: id2str.admDependencyPriv(i) + }); + }; next(); -}, query, response('adm_dependency_detailed')); +}, response('adm_dependency_detailed')); rqf.addField({ name: 'filter', diff --git a/src/libs/routes/population.js b/src/libs/routes/population.js index cd307cdb..f0402daa 100644 --- a/src/libs/routes/population.js +++ b/src/libs/routes/population.js @@ -41,7 +41,7 @@ populationApp.get('/years', (req, res, next) => { populationApp.get('/city_size', (req, res, next) => { req.result = [ - {id: 1, name: "até 5000"}, + {id: 1, name: "0 - 5000"}, {id: 2, name: "5001 - 10000"}, {id: 3, name: "10001 - 20000"}, {id: 4, name: "20001 - 50000"}, -- GitLab From 4344d1d71006d0bfbbb36783e1cb274a5e1e6108 Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Thu, 20 Sep 2018 10:58:15 -0300 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a5ddfd5..59101d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 1.7.0 - 2018-09-20 +# Changed +- Fix out of school route +- Fix pib-per-capita route +- Fix filters in infrastructure route +- Remove filters in transport route + ## 1.6.1 - 2018-08-23 # Changed - Fix return json name in transport route -- GitLab