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

[ADD] Age range dimension/filter is now required to use the indicator

parent ca413456
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...
...@@ -134,6 +134,18 @@ rateSchoolNewApp.get('/income_range', (req, res, next) => { ...@@ -134,6 +134,18 @@ rateSchoolNewApp.get('/income_range', (req, res, next) => {
next(); next();
}, response('income_range')); }, response('income_range'));
rateSchoolNewApp.get('/age_range', (req, res, next) => {
req.result = [
{id: 1, name: '0 a 3 anos'},
{id: 2, name: '4 a 5 anos'},
{id: 3, name: '6 a 10 anos'},
{id: 4, name: '11 a 14 anos'},
{id: 5, name: '15 a 17 anos'},
{id: 6, name: '18 a 24 anos'}
];
next();
}, response('age_range'));
rqf.addField({ rqf.addField({
name: 'filter', name: 'filter',
field: false, field: false,
...@@ -303,6 +315,8 @@ function matchQueries(attendsSchoolObj, populationObj) { ...@@ -303,6 +315,8 @@ function matchQueries(attendsSchoolObj, populationObj) {
} }
rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
if ("age_range" in req.filter || "age_range" in req.dims) {
// As we will need to do two requests, they'll be stored in a list // As we will need to do two requests, they'll be stored in a list
req.querySet = [] req.querySet = []
...@@ -334,15 +348,22 @@ rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -334,15 +348,22 @@ rateSchoolNewApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.order('pnad_novo.ano_ref') .order('pnad_novo.ano_ref')
.order('pnad_novo.faixa_etaria') .order('pnad_novo.faixa_etaria')
req.querySet.push(full_population); req.querySet.push(full_population);
}
next(); next();
}, multiQuery, (req, res, next) => { }, multiQuery, (req, res, next) => {
if ("age_range" in req.filter || "age_range" in req.dims) {
// The multiple requests are made. Then we need to calculate the percetange. So the function // The multiple requests are made. Then we need to calculate the percetange. So the function
// below is used // below is used
let newObj = matchQueries(req.result[0], req.result[1]); let newObj = matchQueries(req.result[0], req.result[1]);
req.result = newObj; req.result = newObj;
} else {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
next(); next();
}, id2str.transform(false), response('rateSchoolNew')); }, 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