Skip to content
Snippets Groups Projects
Commit e7f8b99a authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Routes aux

parent b67af1d6
No related branches found
No related tags found
3 merge requests!116Release v1.0.0,!44Feature multiple where,!37Route_Class
Pipeline #
......@@ -15,6 +15,54 @@ const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
let rqfCount = new ReqQueryFields();
// Complete range of the enrollments dataset.
// Returns a tuple of start and ending years of the complete enrollments dataset.
classApp.get('/year_range', (req, res, next) => {
req.sql.from('matricula')
.field('MIN(matricula.ano_censo)', 'start_year')
.field('MAX(matricula.ano_censo)', 'end_year');
next();
}, query, response('range'));
classApp.get('/location', (req, res, next) => {
req.sql = squel.select()
.field('id')
.field('descricao', 'name')
.from('localizacao');
next();
}, query, response('location'));
// Returns all adm dependencies
classApp.get('/adm_dependency', (req, res, next) => {
req.sql.from('dependencia_adm')
.field('id')
.field('nome', 'name')
.where('id <= 4');
next();
}, query, response('adm_dependency'));
classApp.get('/adm_dependency_detailed', (req, res, next) => {
req.sql.from('dependencia_adm')
.field('id', 'id')
.field('nome', 'name');
next();
}, query, response('adm_dependency_detailed'));
// Returns all periods avaible
classApp.get('/period', (req, res, next) => {
req.sql.from('turma_turno')
.field('id')
.field('nome', 'name');
next();
}, query, response('period'));
// Returns all educational levels avaible
classApp.get('/education_level', (req, res, next) => {
req.sql.from('etapas_mod_ensino_segmento')
.field('id')
.field('nome', 'name');
next();
}, query, response('education_level'));
rqfCount.addField({
name: 'filter',
......@@ -86,6 +134,21 @@ rqfCount.addField({
foreign: 'dependencia_adm_id',
foreignTable: 'turma'
}
}).addValue({
name: 'location',
table: 'localizacao',
tableField: 'descricao',
resultField: 'location_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'localizacao_id',
foreignTable: 'turma'
}
}).addValue({
name:'school_level',
table: 'etapas_mod_ensino_segmento ',
......@@ -102,20 +165,20 @@ rqfCount.addField({
foreignTable: 'turma'
}
}).addValue({
name:'dependencia_priv',
table: 'escola',
tableField: 'dependencia_adm_priv',
resultField: 'dependencia_adm_priv',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'escola_id',
foreignTable: 'turma'
}
name: 'adm_dependency_detailed',
table: 'dependencia_adm',
tableField: 'nome',
resultField: 'adm_dependency_detailed_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'dependencia_adm_priv',
foreignTable: 'turma'
}
}).addValue({
name:'period',
table: 'turma_turno',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment