diff --git a/src/libs/routes_v1/rateSchoolNew.js b/src/libs/routes_v1/rateSchoolNew.js index 0b20900a963a3e6690aba80b2cf35ed30dc90099..7e1bb60b0bbcb7ed1bae1c002ba5558fb2a4d5ff 100644 --- a/src/libs/routes_v1/rateSchoolNew.js +++ b/src/libs/routes_v1/rateSchoolNew.js @@ -45,9 +45,94 @@ rateSchoolNewApp.use(cache('15 day')); rateSchoolNewApp.get('/years', (req, res, next) => { req.sql.from('pnad_novo') .field('DISTINCT pnad_novo.ano_ref', 'year') + .where('pnad_novo.ano_ref> 2018') next(); }, query, response('years')); +PnadNovoApp.get('/region', (req, res, next) => { + req.result = [] + for (let i = 1; i < 6; i++) { + req.result.push({ + id: i, name: id2str.regionCode(i) + }); + } + + next(); +}, response('region')); + +PnadNovoApp.get('/cap_code', (req, res, next) => { + req.result = [] + for (let i = 11; i < 54; i++) { + if (id2str.capitalCode(i) !== 'Não informado') { + req.result.push({ + id: i, name: id2str.capitalCode(i) + }); + } + } + req.result.push({id: 99, name: id2str.capitalCode(99)}); + + next(); +}, response('cap_code')); + +PnadNovoApp.get('/metro_code', (req, res, next) => { + req.result = [] + for (let i = 13; i < 53; i++) { + if (id2str.metroCode(i) !== 'Não informado') { + req.result.push({ + id: i, name: id2str.metroCode(i) + }); + } + } + req.result.push({id: 99, name: id2str.metroCode(99)}); + + next(); +}, response('metro_code')); + +PnadNovoApp.get('/gender', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.gender(i) + }); + } + next(); +}, response('gender')); + +PnadNovoApp.get('/bolsa_familia', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.attendsSchool(i) + }); + } + req.result.push({id: 9, name: id2str.attendsSchool(9)}); + next(); +}, response('bolsa_familia')); + +PnadNovoApp.get('/state', (req, res, next) => { + req.result = [] + for (let i = 11; i < 54; i++) { + if (id2str.stateName(i) !== 'Não declarada') { + req.result.push({ + id: i, name: id2str.stateName(i) + }); + } + } + req.result.push({id: 99, name: id2str.stateName(99)}); + + next(); +}, response('state')); + +PnadNovoApp.get('/income_range', (req, res, next) => { + req.result = [] + for (let i = 1; i < 8; i++) { + req.result.push({ + id: i, name: id2str.incomeRange(i) + }); + } + req.result.push({id: 9, name: id2str.incomeRange(9)}); + next(); +}, response('income_range')); rqf.addField({ name: 'filter',