diff --git a/src/libs/convert/ruralLocation.js b/src/libs/convert/ruralLocation.js new file mode 100644 index 0000000000000000000000000000000000000000..7fa97d527a5001cf8d8ebf2f0a2fac4fcdd6cfe5 --- /dev/null +++ b/src/libs/convert/ruralLocation.js @@ -0,0 +1,16 @@ +module.exports = function ruralLocation(id) { + switch (id) { + case 1: + return 'Urbana'; + case 2: + return 'Rural'; + case 3: + return 'Rural - Ãrea de assentamento'; + case 4: + return 'Rural - Terra indÃgena'; + case 5: + return 'Rural - Ãrea remanescente de quilombos'; + case 6: + return 'Rural - Unidade de uso sustentável'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index ae9ae4634767e7a14a2ea197335d05169ea10618..be74c3c2bbe0823c93e859c4979a4165bedf7de2 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -4,6 +4,7 @@ const period = require(`${libs}/convert/period`); const schoolYear = require(`${libs}/convert/schoolYear`); const admDependency = require(`${libs}/convert/admDependency`); const location = require(`${libs}/convert/location`); +const ruralLocation = require(`${libs}/convert/ruralLocation`); const ethnicGroup = require(`${libs}/convert/ethnicGroup`); const agreement = require(`${libs}/convert/agreement`); const booleanVariable = require(`${libs}/convert/booleanVariable`); @@ -20,6 +21,7 @@ const ids = { adm_dependency_id: admDependency, adm_dependency_detailed_id: admDependency, location_id: location, + rural_location_id: ruralLocation, ethnic_group_id: ethnicGroup, agreement_id: agreement, integral_time_id: booleanVariable, diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 39291ddc4ab0073823c2b34972638da0e2f751ed..7238959e28ea3789a877cb73960f6d6d485fb12b 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -34,6 +34,18 @@ classApp.get('/location', (req, res, next) => { next(); }, query, response('location')); +classApp.get('/rural_location', (req, res, next) => { + req.result = [ + {id: 1, name: "Urbana"}, + {id: 2, name: "Rural"}, + {id: 3, name: "Rural - Ãrea de assentamento"}, + {id: 4, name: "Rural - Terra indÃgena"}, + {id: 5, name: "Rural - Ãrea remanescente de quilombos"}, + {id: 6, name: "Rural - Unidade de uso sustentável"} + ]; + next(); +}, response('rural_location')); + // Returns all adm dependencies classApp.get('/adm_dependency', (req, res, next) => { req.sql.from('dependencia_adm') @@ -171,6 +183,16 @@ rqfCount.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'rural_location', + table: 'turma', + tableField: 'localidade_area_rural', + resultField: 'rural_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localidade_area_rural' + } }).addValue({ name:'education_level_mod', table: 'turma', diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index c4d13a9820d137e5f101dfc40a1a8220a04d72e2..6f1329d4afd02440e699964865adb14ff1f3351c 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -35,6 +35,18 @@ enrollmentApp.get('/location', (req, res, next) => { next(); }, query, response('location')); +enrollmentApp.get('/rural_location', (req, res, next) => { + req.result = [ + {id: 1, name: "Urbana"}, + {id: 2, name: "Rural"}, + {id: 3, name: "Rural - Ãrea de assentamento"}, + {id: 4, name: "Rural - Terra indÃgena"}, + {id: 5, name: "Rural - Ãrea remanescente de quilombos"}, + {id: 6, name: "Rural - Unidade de uso sustentável"} + ]; + next(); +}, response('rural_location')); + // Returns all school years available enrollmentApp.get('/school_year', (req, res, next) => { req.sql.from('serie_ano') @@ -238,6 +250,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'rural_location', + table: 'matricula', + tableField: 'localidade_area_rural', + resultField: 'rural_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localidade_area_rural' + } }).addValue({ name: 'min_year', table: 'matricula', diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index 659730083c3c49928eb8a6d4adb241a1940f7614..2e6a37ad80f8a08b85f62bba8137abfa5b59e717 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -33,6 +33,18 @@ schoolApp.get('/location', (req, res, next) => { next(); }, response('location')); +schoolApp.get('/rural_location', (req, res, next) => { + req.result = [ + {id: 1, name: "Urbana"}, + {id: 2, name: "Rural"}, + {id: 3, name: "Rural - Ãrea de assentamento"}, + {id: 4, name: "Rural - Terra indÃgena"}, + {id: 5, name: "Rural - Ãrea remanescente de quilombos"}, + {id: 6, name: "Rural - Unidade de uso sustentável"} + ]; + next(); +}, response('rural_location')); + schoolApp.get('/adm_dependency', (req, res, next) => { req.sql.from('dependencia_adm') .field('id') @@ -483,6 +495,16 @@ rqfCount.addField({ type: 'integer', field: 'cod_localizacao' } +}).addValue({ + name: 'rural_location', + table: 'escola', + tableField: 'localidade_area_rural', + resultField: 'rural_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localidade_area_rural' + } }).addValue({ name: 'cook_room', table: 'escola', diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 130bd9fa3b30d793922b5795f2e519062fbd2689..470801ceb768279dd354e9d2c89a359c1b148fde 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -56,6 +56,18 @@ teacherApp.get('/location', (req, res, next) => { next(); }, query, response('location')); +teacherApp.get('/rural_location', (req, res, next) => { + req.result = [ + {id: 1, name: "Urbana"}, + {id: 2, name: "Rural"}, + {id: 3, name: "Rural - Ãrea de assentamento"}, + {id: 4, name: "Rural - Terra indÃgena"}, + {id: 5, name: "Rural - Ãrea remanescente de quilombos"}, + {id: 6, name: "Rural - Unidade de uso sustentável"} + ]; + next(); +}, response('rural_location')); + teacherApp.get('/education_type', (req, res, next) => { req.sql.from('docente') .field('DISTINCT nivel_tipo_formacao', 'id') @@ -201,6 +213,16 @@ rqf.addField({ type: 'integer', field: 'cod_localizacao' } +}).addValue({ + name: 'rural_location', + table: 'docente', + tableField: 'localidade_area_rural', + resultField: 'rural_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localidade_area_rural' + } }).addValue({ name: 'min_year', table: 'docente', diff --git a/src/test/class.js b/src/test/class.js index 32f89e3bacec3313f59067b8ff1102da230b037b..7c20fc91ad949f65b0dcc1916ffd100a2bcbda4f 100644 --- a/src/test/class.js +++ b/src/test/class.js @@ -38,6 +38,20 @@ describe('request class', () => { }); }); + it('should list the rural locations', (done) => { + chai.request(server) + .get('/api/v1/class/rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the education level', (done) => { chai.request(server) .get('/api/v1/class/education_level_mod') @@ -170,4 +184,18 @@ describe('request class', () => { done(); }); }); + + it('should list class with dimension rural_location', (done) => { + chai.request(server) + .get('/api/v1/class?dims=rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('rural_location_name'); + res.body.result[0].should.not.have.property('rural_location_id'); + done(); + }); + }); }); diff --git a/src/test/enrollment.js b/src/test/enrollment.js index ca4bf0314fc8335147d7b35b20d510e49e772b20..efa5c160a5607f2e9b14136e14b6795d3ac2b232 100644 --- a/src/test/enrollment.js +++ b/src/test/enrollment.js @@ -52,6 +52,20 @@ describe('request enrollments', () => { }); }); + it('should list the rural locations', (done) => { + chai.request(server) + .get('/api/v1/enrollment/rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the school year', (done) => { chai.request(server) .get('/api/v1/enrollment/school_year') @@ -297,6 +311,20 @@ describe('request enrollments', () => { }); }); + it('should list enrollment with dimension rural_location', (done) => { + chai.request(server) + .get('/api/v1/enrollment?dims=rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('rural_location_name'); + res.body.result[0].should.not.have.property('rural_location_id'); + done(); + }); + }); + it('should list enrollment with dimension school year', (done) => { chai.request(server) .get('/api/v1/enrollment?dims=school_year') diff --git a/src/test/schoolCount.js b/src/test/schoolCount.js index 0a94f2d7a9b235cef2d2136f5d52f75ad6cfe12d..35d84e3b7b3346fd890062066c992df43bd4c7b6 100644 --- a/src/test/schoolCount.js +++ b/src/test/schoolCount.js @@ -39,6 +39,20 @@ describe('request schools count', () => { }); }); + it('should list the rural locations', (done) => { + chai.request(server) + .get('/api/v1/school/rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the administrative dependencies', (done) => { chai.request(server) .get('/api/v1/school/adm_dependency') @@ -637,4 +651,18 @@ describe('request schools count', () => { done(); }); }); + + it('should list school with dimension rural_location', (done) => { + chai.request(server) + .get('/api/v1/school/count?dims=rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('rural_location_name'); + res.body.result[0].should.not.have.property('rural_location_id'); + done(); + }); + }); }); diff --git a/src/test/teacher.js b/src/test/teacher.js index 0b3cb7bdd528ddde998d5fc35e1aabd35e95b1c9..7022188f9b546e7bea85dc49cbddb8ebe9d3a1e2 100644 --- a/src/test/teacher.js +++ b/src/test/teacher.js @@ -52,6 +52,20 @@ describe('request teachers', () => { }); }); + it('should list the rural locations', (done) => { + chai.request(server) + .get('/api/v1/teacher/rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the education level mod', (done) => { chai.request(server) .get('/api/v1/teacher/education_level_mod') @@ -241,6 +255,20 @@ describe('request teachers', () => { }); }); + it('should list teacher count with dimension rural_location', (done) => { + chai.request(server) + .get('/api/v1/teacher?dims=rural_location') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('rural_location_name'); + res.body.result[0].should.not.have.property('rural_location_id'); + done(); + }); + }); + it('should list teacher count with dimension education_level_mod', (done) => { chai.request(server) .get('/api/v1/teacher?dims=education_level_mod')