Skip to content
Snippets Groups Projects
Commit adea4bfb authored by Fernando Gbur dos Santos's avatar Fernando Gbur dos Santos
Browse files

[ADD] Matching queries and trying to make the first route version

parent b4c6885d
No related branches found
No related tags found
3 merge requests!417[ADD] Indicator "Taxa de Atendimento Educacional" updated on production!,!416[ADD] Route almost ready, some tests needed. Comments added and filters that...,!414[ADD] Route almost ready, some tests needed. Comments added and filters that...
......@@ -313,22 +313,25 @@ rqf.addField({
});
function matchQueries(attendsSchoolObj, populationObj) {
let match = []
let match = [];
for (let i = 0; i < attendsSchoolObj.length; i++) {
let newObj = {}
let newObj = {};
console.log("====TESTE====")
console.log(attendsSchoolObj[i])
console.log(populationObj[i])
console.log("====TESTE====")
newObj.total = (attendsSchoolObj.total / populationObj.total) * 100;
newObj.faixa_etaria = attendsSchoolObj.faixa_etaria;
newObj.year = attendsSchoolObj.year;
match.push(newObj);
}
return match;
}
rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.querySet = []
let attends_school = req.sql.clone()
let attends_school = req.sql.clone();
attends_school.from('pnad_novo')
.field('round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)', 'total')
.field('pnad_novo.faixa_etaria')
......@@ -338,9 +341,9 @@ rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('pnad_novo.faixa_etaria')
.order('pnad_novo.ano_ref')
.order('pnad_novo.faixa_etaria')
req.querySet.push(attends_school)
req.querySet.push(attends_school);
let full_population = req.sql.clone()
let full_population = req.sql.clone();
full_population.from('pnad_novo')
.field('round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)', 'total')
.field('pnad_novo.faixa_etaria')
......@@ -350,13 +353,12 @@ rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('pnad_novo.faixa_etaria')
.order('pnad_novo.ano_ref')
.order('pnad_novo.faixa_etaria')
req.querySet.push(full_population)
req.querySet.push(full_population);
next();
}, multiQuery, (req, res, next) => {
//req.result = matchQueries(req.result[0], req.result[1])
matchQueries(req.result[0], req.result[1])
req.result = matchQueries(req.result[0], req.result[1]);
next();
}, id2str.transform(false), response('rateSchoolNew'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment