diff --git a/src/libs/convert/capitalCode.js b/src/libs/convert/capitalCode.js index 2e4774f53cd92e9b6f69360b8664b538b2fe6b63..fe7c0862591b81561c96d326d5f824467d9ffaba 100644 --- a/src/libs/convert/capitalCode.js +++ b/src/libs/convert/capitalCode.js @@ -74,8 +74,10 @@ module.exports = function capitalCode(id) { return 'Goiânia'; case 53: return 'Brasília'; - default: + case 99: return 'Não é capital'; + default: + return 'Não informado'; } }; diff --git a/src/libs/convert/ethnicGroupNewPnad.js b/src/libs/convert/ethnicGroupNewPnad.js index cfbd60e176b014a66fc2ba2dd681cb5203320e38..702a90fffd64cca924c4e5d186d25fdd6092a9b8 100644 --- a/src/libs/convert/ethnicGroupNewPnad.js +++ b/src/libs/convert/ethnicGroupNewPnad.js @@ -31,6 +31,6 @@ module.exports = function ethnicGroupNewPnad(id) { case 5: return 'Indígena'; case 9: - return 'Sem declaração'; + return 'Não declarado'; } }; diff --git a/src/libs/convert/metroCode.js b/src/libs/convert/metroCode.js index e7729bb454e0c6b5a8785a84c22d1cb9c59b0d3a..0442f2c757a31b81828e28574b55bb50783c873b 100644 --- a/src/libs/convert/metroCode.js +++ b/src/libs/convert/metroCode.js @@ -62,7 +62,9 @@ module.exports = function metroCode(id) { return 'Região Metropolitana de Vale do Rio Cuiabá'; case 52: return 'Região Metropolitana de Goiânia'; - default: + case 99: return 'Não é região metropolitana ou região administrativa integrada'; + default: + return 'Não informado'; } }; diff --git a/src/libs/convert/modality.js b/src/libs/convert/modality.js index a4c56f52ae800dace35c344245b30cf4c741655a..d57d93381ce9e49dcf2ec555f6cd75fb26cbfe01 100644 --- a/src/libs/convert/modality.js +++ b/src/libs/convert/modality.js @@ -26,6 +26,8 @@ module.exports = function modality(id) { return 'A distância'; case 3: return 'Não informado'; + case 9: + return 'Sem dados para 2022'; case 99: return 'Não frequenta instituição de ensino' } diff --git a/src/libs/convert/modalityShift.js b/src/libs/convert/modalityShift.js index 23661130f016c476ff6da45217b0719ab59c1a15..7cde03d02bb8f4da76c7e4a998b582fd81dc63b5 100644 --- a/src/libs/convert/modalityShift.js +++ b/src/libs/convert/modalityShift.js @@ -20,8 +20,6 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function modalityShift(id) { switch (id) { - case null: - return 'Não informado'; case 1: return 'Matutino'; case 2: @@ -36,6 +34,8 @@ module.exports = function modalityShift(id) { return 'Não se aplica - pós graduação presencial'; case 7: return 'EaD ou semipresencial'; + case 9: + return 'Não informado'; case 99: return 'Não frequenta instituição de ensino'; } diff --git a/src/libs/convert/stateName.js b/src/libs/convert/stateName.js index 092969fa961aceaf262db094c383a7362267eee8..9254af006be3f66badfd578c98fc17a2c120c927 100644 --- a/src/libs/convert/stateName.js +++ b/src/libs/convert/stateName.js @@ -76,5 +76,7 @@ module.exports = function stateName(id) { return 'Distrito Federal'; case 99: return 'Exterior'; + default: + return 'Não declarada'; } }; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index d15505d31fc165e79b4e2033b10eb6cecf02c184..02273a8bff361981bc0079312881afdf052e439c 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -217,7 +217,7 @@ const ids = { bolsa_familia_id: attendsSchool, new_pnad_ethnic_group_id: ethnicGroupNewPnad, cap_code_id: capitalCode, - reg_code_id: regionCode, + region_id: regionCode, metro_code_id: metroCode, modality_shift_id: modalityShift, income_range_id: incomeRange diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js index a2b13aa0bfa834c1d7f284356842a57dbe190096..bab8cdf981e2411b839f1da33a2f24ca5f17a72c 100644 --- a/src/libs/routes_v1/newPnad.js +++ b/src/libs/routes_v1/newPnad.js @@ -77,12 +77,12 @@ PnadNovoApp.get('/years_of_study', (req, res, next) => { PnadNovoApp.get('/instruction_level', (req, res, next) => { req.result = [] - for (let i = 1; i < 9; i++) { + for (let i = 1; i < 8; i++) { req.result.push({ id: i, name: id2str.instructionLevel(i) }); } - + req.result.push({id: 99, name: id2str.instructionLevel(99)}); next(); }, response('instruction_level')); @@ -97,18 +97,7 @@ PnadNovoApp.get('/new_pnad_adm_dependency', (req, res, next) => { next(); }, response('new_pnad_adm_dependency')); -PnadNovoApp.get('/reg_code', (req, res, next) => { - req.result = [] - for (let i = 1; i < 6; i++) { - req.result.push({ - id: i, name: id2str.regionCode(i) - }); - } - - next(); -}, response('reg_code')); - -PnadNovoApp.get('/reg_code', (req, res, next) => { +PnadNovoApp.get('/region', (req, res, next) => { req.result = [] for (let i = 1; i < 6; i++) { req.result.push({ @@ -117,15 +106,18 @@ PnadNovoApp.get('/reg_code', (req, res, next) => { } next(); -}, response('reg_code')); +}, 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')); @@ -133,17 +125,20 @@ PnadNovoApp.get('/cap_code', (req, res, next) => { 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('/attended_modality', (req, res, next) => { req.result = [] - for (let i = 1; i < 15; i++) { + for (let i = 1; i < 16; i++) { req.result.push({ id: i, name: id2str.attendedModality(i) }); @@ -154,12 +149,12 @@ PnadNovoApp.get('/attended_modality', (req, res, next) => { PnadNovoApp.get('/income_range', (req, res, next) => { req.result = [] - for (let i = 1; i < 15; i++) { + for (let i = 1; i < 8; i++) { req.result.push({ - id: i, name: id2str.attendedModality(i) + id: i, name: id2str.incomeRange(i) }); } - req.result.push({id: 99, name: id2str.attendedModality(99)}); + req.result.push({id: 9, name: id2str.incomeRange(9)}); next(); }, response('income_range')); @@ -170,7 +165,6 @@ PnadNovoApp.get('/attends_school', (req, res, next) => { id: i, name: id2str.attendsSchool(i) }); } - req.result.push({id: 9, name: id2str.attendsSchool(9)}); next(); }, response('attends_school')); @@ -217,6 +211,44 @@ PnadNovoApp.get('/modality', (req, res, next) => { next(); }, response('modality')); +PnadNovoApp.get('/modality_shift', (req, res, next) => { + req.result = [] + for (let i = 1; i < 8; i++) { + req.result.push({ + id: i, name: id2str.modalityShift(i) + }); + } + req.result.push({id: 9, name: id2str.modalityShift(9)}); + req.result.push({id: 99, name: id2str.modalityShift(99)}); + next(); +}, response('modality_shift')); + +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('/age_range_all', (req, res, next) => { + req.result = [] + for (let i = 1; i < 12; i++) { + req.result.push({ + id: i, name: id2str.ageRangeAll(i) + }); + } + + next(); +}, response('age_range_all')); + + rqf.addField({ name: 'filter', field: false, @@ -237,8 +269,8 @@ rqf.addField({ }).addValue({ name: 'state', table: 'estado', - tableField: ['nome', 'id'], - resultField: ['state_name', 'state_id'], + tableField: ['id', 'nome'], + resultField: ['state_id', 'state_nome'], where: { relation: '=', type: 'integer', @@ -265,16 +297,6 @@ rqf.addField({ foreign: 'cod_uf', foreignTable: 'pnad_novo' } -}).addValue({ - name: 'illiteracy', - table: 'pnad_novo', - tableField: 'analfabetismo', - resultField: 'illiteracy_id', - where: { - relation: '=', - type: 'integer', - field: 'analfabetismo' - } }).addValue({ name: 'years_of_study', table: 'pnad_novo', @@ -335,6 +357,16 @@ rqf.addField({ type: 'integer', field: 'nivel_etapa_modalidade_freq' } +}).addValue({ + name: 'illiteracy', + table: 'pnad_novo', + tableField: 'analfabetismo', + resultField: 'illiteracy_id', + where: { + relation: '=', + type: 'integer', + field: 'analfabetismo' + } }).addValue({ name: 'modality_shift', table: 'pnad_novo', @@ -343,7 +375,7 @@ rqf.addField({ where: { relation: '=', type: 'integer', - field: 'modality_shift_id' + field: 'turno_nivel_etapa' } }).addValue({ name: 'bolsa_familia', @@ -366,7 +398,7 @@ rqf.addField({ field: 'cor_raca' } }).addValue({ - name: 'age_range', + name: 'age_range_all', table: 'pnad_novo', tableField: 'faixa_etaria', resultField: 'age_range_all_id', @@ -378,12 +410,12 @@ rqf.addField({ }).addValue({ name: 'income_range', table: 'pnad_novo', - tableField: 'faixa_rendimento', + tableField: 'faixa_rendimento_aux', resultField: 'income_range_id', where: { relation: '=', type: 'integer', - field: 'faixa_rendimento' + field: 'faixa_rendimento_aux' } }).addValue({ name: 'gender', @@ -406,10 +438,10 @@ rqf.addField({ field: 'cod_cap' } }).addValue({ - name: 'reg_code', + name: 'region', table: 'pnad_novo', tableField: 'cod_regiao', - resultField: 'reg_code_id', + resultField: 'region_id', where: { relation: '=', type: 'integer', @@ -476,16 +508,6 @@ rqf.addField({ type: 'integer', field: 'microrregiao_id' } -}).addValue({ - name: 'region', - table: 'pnad_novo', - tableField: 'cod_regiao', - resultField: 'reg_code_id', - where: { - relation: '=', - type: 'integer', - field: 'cod_regiao', - } }); PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { @@ -496,6 +518,6 @@ PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .order('pnad_novo.ano_ref') console.log(req.sql.toString()) next(); -}, query, id2str.transform(false),response('pnad_novo')); +}, query, id2str.transform(false), response('pnad_novo')); module.exports = PnadNovoApp;