diff --git a/src/libs/routes_v1/studentsReceivingAidTax.js b/src/libs/routes_v1/studentsReceivingAidTax.js index c4509cf84057b5243e9e93f2ae7ccfc992e00a47..b515e37645d918f1ec27b05547f830c481bbb34d 100644 --- a/src/libs/routes_v1/studentsReceivingAidTax.js +++ b/src/libs/routes_v1/studentsReceivingAidTax.js @@ -578,8 +578,21 @@ function matchQueries(queryPartial, queryTotal) { return match; } +function whereCondition(req) { + let where = ""; + + const dims = req.query.dims; + if (dims && dims.includes("income_range")){ + where += `pnad_novo.faixa_rendimento_aux_tx is not null`; + } + + + return where; +} + studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { req.querySet = []; + let where = whereCondition(req); // Subquery para total_pop_maior_25 com filtros dinĂ¢micos let totalEstudantesQueRecebemAuxilio = req.sql.clone(); @@ -587,6 +600,7 @@ studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) = .field("ano_ref", "year") .field("SUM(peso_domicilio_pessoas_com_cal)", "total") .where("recebeu_rendimentos_de_programa_bolsa_familia = 1") + .where(`${where}`) .where("frequenta_escola = 1") .where("ano_ref >= 2019") .group("ano_ref") @@ -598,7 +612,9 @@ studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) = totalEstudantes.from("pnad_novo") .field("ano_ref", "year") .field("SUM(peso_domicilio_pessoas_com_cal)", "total") + .where(`${where}`) .where("frequenta_escola = 1") + .where("ano_ref >= 2019") .group("ano_ref") .order("ano_ref");