diff --git a/src/libs/routes_v1/api.js b/src/libs/routes_v1/api.js index 9880ac847b42e8f32dde87e76a57ac81fb52d088..91086468f4822d64ff597e0dfa3649ab272afa71 100644 --- a/src/libs/routes_v1/api.js +++ b/src/libs/routes_v1/api.js @@ -171,6 +171,8 @@ const adjustedLiquidFrequency = require(`${libs}/routes_v1/adjustedLiquidFrequen const iliteracyRate = require(`${libs}/routes_v1/iliteracyRate`); +const enrollmentRate = require(`${libs}/routes_v1/enrollmentRate`); + api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API v1 is running' }); }); @@ -244,6 +246,7 @@ api.use('/superior_education_conclusion_tax', superiorEducationConclusionTax) api.use('/basic_education_conclusion', basicEducationConclusion); api.use('/adjusted_liquid_frequency', adjustedLiquidFrequency); api.use('/iliteracy_rate', iliteracyRate); +api.use('/enrollment_rate', enrollmentRate); //Publication api.use('/publication', publication); diff --git a/src/libs/routes_v1/enrollmentRate.js b/src/libs/routes_v1/enrollmentRate.js index 1418c19638b63feced533a9df64510f7173501a7..ab2c9018167c5f423c56183c54321d8c8bbd628b 100644 --- a/src/libs/routes_v1/enrollmentRate.js +++ b/src/libs/routes_v1/enrollmentRate.js @@ -56,6 +56,61 @@ EnrollmentRateApp.get('/ageRanges', (req, res, next) => { next(); }, query, response('ageRanges')); +// • Área da Localidade +EnrollmentRateApp.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')); + +// • Capital +EnrollmentRateApp.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')); + +// • Região +EnrollmentRateApp.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')); + +// • UF +EnrollmentRateApp.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')); + + rqf.addField({ name: 'filter', @@ -173,9 +228,9 @@ function matchQueries(queryPartial, queryTotal) { match.push({ year: result.year, age_range: result.age_range, - total: result.total, - total_partial: partial.total_inf_cre, - total_taxa: ((partial.total_inf_cre/result.total) * 100).toFixed(2), + // total: result.total, + // total_partial: partial.total_inf_cre, + total: ((partial.total_inf_cre/result.total) * 100).toFixed(2), }); found = true; break; @@ -183,9 +238,7 @@ function matchQueries(queryPartial, queryTotal) { match.push({ year: result.year, age_range: result.age_range, - total: result.total, - total_partial: partial.total_inf_pre, - total_taxa: ((partial.total_inf_pre/result.total) * 100).toFixed(2), + total: ((partial.total_inf_pre/result.total) * 100).toFixed(2), }); found = true; break; @@ -193,9 +246,7 @@ function matchQueries(queryPartial, queryTotal) { match.push({ year: result.year, age_range: result.age_range, - total: result.total, - total_partial: partial.total_fund_ai, - total_taxa: ((partial.total_fund_ai/result.total) * 100).toFixed(2), + total: ((partial.total_fund_ai/result.total) * 100).toFixed(2), }); found = true; break; @@ -203,9 +254,7 @@ function matchQueries(queryPartial, queryTotal) { match.push({ year: result.year, age_range: result.age_range, - total: result.total, - total_partial: partial.total_fund_af, - total_taxa: ((partial.total_fund_af/result.total) * 100).toFixed(2), + total: ((partial.total_fund_af/result.total) * 100).toFixed(2), }); found = true; break; @@ -213,9 +262,7 @@ function matchQueries(queryPartial, queryTotal) { match.push({ year: result.year, age_range: result.age_range, - total: result.total, - total_partial: partial.total_med, - total_taxa: ((partial.total_med/result.total) * 100).toFixed(2), + total: ((partial.total_med/result.total) * 100).toFixed(2), }); found = true; break;