From da4a8a319a5e0c02c4b43251360694059c3ca3e1 Mon Sep 17 00:00:00 2001 From: tgcl21 <tgcl21@inf.ufpr.br> Date: Wed, 26 Feb 2025 11:31:27 -0300 Subject: [PATCH] fixed instruction level filters --- src/libs/routes_v1/instructionLevel.js | 78 ++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/src/libs/routes_v1/instructionLevel.js b/src/libs/routes_v1/instructionLevel.js index c8b27886..d3cb7d0c 100644 --- a/src/libs/routes_v1/instructionLevel.js +++ b/src/libs/routes_v1/instructionLevel.js @@ -61,6 +61,64 @@ NivelInstrucao.get('/instruction_level', (req, res, next) => { next(); }, response('instruction_level')); +NivelInstrucao.get('/age_range_all', (req, res, next) => { + req.result = [] + + for (let i = 1; i < 9; i++) { + req.result.push({ + id: i, name: id2str.ageRangeAll(i) + }); + + } + req.result.push({id: 99, name: id2str.ageRangeAll(99)}); + next(); +}, response('age_range_all')); + +NivelInstrucao.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')); + +NivelInstrucao.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')); + +NivelInstrucao.get('/location', (req, res, next) => { + req.result = [] + for (let i = 1; i <= 2; i++) { + req.result.push({ + id: i, name: id2str.location(i) + }); + } + + next(); +}, response('location')); + +NivelInstrucao.get('/ethnic_group', (req, res, next) => { + req.result = []; + for(let i = 0; i <=5; ++i) { + req.result.push({ + id: i, + name: id2str.ethnicGroup(i) + }); + } + next(); +}, response('ethnic_group')); + + rqf.addField({ name: 'filter', field: false, @@ -78,16 +136,6 @@ rqf.addField({ type: 'integer', field: 'id' } -}).addValue({ - name: 'location', - table: 'pnad_novo', - tableField: 'tipo_de_area', - resultField: 'location_id', - where: { - relation: '=', - type: 'integer', - field: 'id' - } }).addValue({ name: 'bolsa_familia', table: 'pnad_novo', @@ -223,6 +271,16 @@ rqf.addField({ type: 'integer', field: 'recebeu_rendimentos_de_programa_bolsa_familia' } +}).addValue({ + name: 'location', + table: 'pnad_novo', + tableField: 'situacao_domicilio', + resultField: 'location_id', + where: { + relation: '=', + type: 'integer', + field: 'situacao_domicilio' + } }) NivelInstrucao.get('/', rqf.parse(), rqf.build(), (req, res, next) => { -- GitLab