From 385740b090436093817682fcee648690202ce5cb Mon Sep 17 00:00:00 2001
From: Vytor Calixto <vytorcalixto@gmail.com>
Date: Tue, 3 Apr 2018 09:57:51 -0300
Subject: [PATCH] Fix ethnic group in out of school route

---
 src/libs/routes/outOfSchool.js | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/libs/routes/outOfSchool.js b/src/libs/routes/outOfSchool.js
index 4e507bf6..b3b6e930 100644
--- a/src/libs/routes/outOfSchool.js
+++ b/src/libs/routes/outOfSchool.js
@@ -56,15 +56,17 @@ outOfSchoolApp.get('/full_age_range', (req, res, next) => {
     next();
 }, response('full_age_range'));
 
-outOfSchoolApp.get('/ethnic_group_pnad', (req, res, next) => {
+outOfSchoolApp.get('/ethnic_group', (req, res, next) => {
     req.result = [
-        {id: 0, name: 'Indígena'},
-        {id: 1, name: 'Branca e amarela'},
-        {id: 2, name: 'Preta e parda'},
-        {id: 9, name: 'Sem declaração'}
+        {id: 0, name: 'Sem declaração'},
+        {id: 1, name: 'Branca'},
+        {id: 2, name: 'Preta'},
+        {id: 3, name: 'Parda'},
+        {id: 4, name: 'Amarela'},
+        {id: 5, name: 'Indígena'}
     ];
     next();
-}, response('ethnic_group_pnad'));
+}, response('ethnic_group'));
 
 outOfSchoolApp.get('/location', (req, res, next) => {
     req.result = [
@@ -142,14 +144,14 @@ rqf.addField({
         foreignTable: 'pnad'
     }
 }).addValue({
-    name: 'ethnic_group_pnad',
+    name: 'ethnic_group',
     table: 'pnad',
-    tableField: 'cor_raca',
-    resultField: 'ethnic_group_pnad_id',
+    tableField: 'cor_raca_id',
+    resultField: 'ethnic_group_id',
     where: {
         relation: '=',
         type: 'integer',
-        field: 'cor_raca'
+        field: 'cor_raca_id'
     }
 }).addValue({
     name: 'min_year',
@@ -176,7 +178,7 @@ rqf.addField({
 }).addValue({
     name: 'full_age_range',
     table: 'pnad',
-    tableField: 'idade_31_03',
+    tableField: 'faixa_etaria_31_03',
     resultField: 'full_age_range_id',
     where: {
         relation: '=',
-- 
GitLab