From 9c9b68cd6162e369941f113268f03b8a5376b326 Mon Sep 17 00:00:00 2001
From: tgcl21 <tgcl21@inf.ufpr.br>
Date: Mon, 10 Mar 2025 10:14:16 -0300
Subject: [PATCH] started frontend

---
 src/libs/routes_v1/api.js            |  3 ++
 src/libs/routes_v1/enrollmentRate.js | 77 ++++++++++++++++++++++------
 2 files changed, 65 insertions(+), 15 deletions(-)

diff --git a/src/libs/routes_v1/api.js b/src/libs/routes_v1/api.js
index 9880ac84..91086468 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 1418c196..ab2c9018 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;
-- 
GitLab