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

[ADD] Trying to use multiple queries in the new route

parent 3da1b4ce
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...
......@@ -32,6 +32,8 @@ const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const multiQuery = require(`${libs}/middlewares/multiQuery`);
const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`);
......@@ -311,7 +313,10 @@ rqf.addField({
});
rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('pnad_novo')
req.querySet = []
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')
.field('pnad_novo.ano_ref', 'year')
......@@ -320,8 +325,22 @@ rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('pnad_novo.faixa_etaria')
.order('pnad_novo.ano_ref')
.order('pnad_novo.faixa_etaria')
console.log(req.sql.toString())
req.querySet.push(attends_school)
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')
.field('pnad_novo.ano_ref', 'year')
.where('pnad_novo.ano_ref >= 2019')
.group('pnad_novo.ano_ref')
.group('pnad_novo.faixa_etaria')
.order('pnad_novo.ano_ref')
.order('pnad_novo.faixa_etaria')
next();
}, query, id2str.transform(false), response('rate_school_new'));
}, multiQuery, (req, res, next) => {
console.log(req.result)
}, id2str.transform(false), response('rateSchoolNew'));
module.exports = rateSchoolNewApp;
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