Skip to content
Snippets Groups Projects
Commit 1d80761f authored by tgcl21's avatar tgcl21
Browse files

Problems with api

parent a789af80
Branches
No related tags found
1 merge request!451Teachers ies
......@@ -43,12 +43,12 @@ gulp.task('compile', ['lint'], () => {
gulp.src('src/**/*.js')
.pipe(cache.filter()) // cache source files
.pipe(babel()) // compile only modified files
// .pipe(cache.cache()) // cache compiled files
.pipe(cache.cache()) // cache compiled files
.pipe(gulp.dest('build')); // move compiled files to build directory
});
gulp.task('build', ['compile'], () => {
var filesToCopy = [ 'config.json', 'package.json' ];
var filesToCopy = [ 'config.json', 'package.json', '.eslintignore', '.eslintrc.json' ];
// copy configuration file to build directory
gulp.src(filesToCopy)
.pipe(gulp.dest('build'));
......@@ -93,24 +93,16 @@ gulp.task('test', ['pre-test'], () => {
});
});
gulp.task('watch', ['compile'], () => {
gulp.task('watch', () => {
console.log('Watching source directory for changes');
gulp.watch('src/**/*.js').on('change', () => {
return gulp.watch('src/**/*.js').on('change', () => {
console.log('Recompiling source');
gulp.start('compile');
console.log('Source recompilation done');
});
});
gulp.task('run', () => {
process.chdir('build');
nodemon({
script: 'server.js',
tasks: ['watch'],
ignore: ["test/test.js", "gulpfile.babel.js"],
ext: 'js html json',
env: { 'NODE_ENV': process.env.NODE_ENV }
});
gulp.task('default', () => {
console.log("Não execuatar apenas gulp, execute da forma:");
console.log("\t\tgulp <task>");
});
gulp.task('default', ['run']);
......@@ -157,6 +157,8 @@ const email = require(`${libs}/routes_v1/email`);
const uniLocalOfferAggregate = require(`${libs}/routes_v1/uniLocalOfferAggregate`)
const iesTeachers = require(`${libs}/routes_v1/iesTeachers`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API v1 is running' });
});
......@@ -223,7 +225,7 @@ api.use('/employeesAggregate', employeesAggregate);
api.use('/course_aggregate', courseAggregate);
api.use('/federativeEntity', federativeEntity);
api.use('/uni_offer_aggregate', uniLocalOfferAggregate);
api.use('/teacher_ies', iesTeachers);
//Publication
api.use('/publication', publication);
......
/*
Copyright (C) 2024 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of simcaq-node.
simcaq-node is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simcaq-node is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/
const express = require('express');
const iesTeachers = express.Router();
const libs = `${process.cwd()}/libs`;
const squel = require('squel');
const query = require(`${libs}/middlewares/query`).query;
const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
let rqf = new ReqQueryFields();
iesTeachers.use(cache('15 day'));
iesTeachers.get('/years', (req, res, next) => {
req.sql.from('docente_ies_agregado')
.field('DISTINCT docente_ies_agregado.ano_censo', 'year')
next();
}, query, response('years'));
iesTeachers.get('/qtd_doc_ex_com_deficiencia', (req, res, next) => {
req.sql.from('docente_ies_agregado')
.field('sum(docente_ies_agregado.qtd_doc_ex_com_deficiencia)', 'total')
.field('docente_ies_agregado.ano_censo', 'year')
.field('docente_ies_agregado.nome_ies', 'university_name')
.field('docente_ies_agregado.cod_ies', 'university_id')
.group('docente_ies_agregado.cod_ies')
.group('docente_ies_agregado.nome_ies')
.group('docente_ies_agregado.ano_censo')
.order('docente_ies_agregado.ano_censo')
next();
}, query, response('qt_doc_ex_com_deficiencia'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'id',
table: 'docente_ies_agregado',
tableField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'id'
}
}).addValue({
name: 'state',
table: 'estado',
tableField: ['id', 'nome'],
resultField: ['state_id', 'state_nome'],
where: {
relation: '=',
type: 'integer',
field: 'id',
},
join: {
primary: 'id',
foreign: 'cod_uf',
foreignTable: 'docente_ies_agregado'
}
}).addValue({
name: 'university',
table: 'docente_ies_agregado',
tableField: ['cod_ies', 'nome_ies'],
resultField: ['university_id', 'university_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ies'
}
}).addValue({
name: 'min_year',
table: 'docente_ies_agregado',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '>=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'max_year',
table: 'docente_ies_agregado',
tableField: '',
resultField: 'year',
where: {
relation: '<=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'qtd_doc_ex_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_fem',
resultField: 'qtd_doc_ex_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_fem'
}
}).addValue({
name: 'qtd_doc_ex_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_masc',
resultField: 'qtd_doc_ex_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_masc'
}
}).addValue({
name: 'qtd_doc_ex_branca',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_branca',
resultField: 'qtd_doc_ex_branca',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_branca'
}
}).addValue({
name: 'qtd_doc_ex_preta',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_preta',
resultField: 'qtd_doc_ex_preta',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_preta'
}
}).addValue({
name: 'qtd_doc_ex_parda',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_parda',
resultField: 'qtd_doc_ex_parda',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_parda'
}
}).addValue({
name: 'qtd_doc_ex_amarela',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_amarela',
resultField: 'qtd_doc_ex_amarela',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_amarela'
}
}).addValue({
name: 'qtd_doc_ex_indigena',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_indigena',
resultField: 'qtd_doc_ex_indigena',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_indigena'
}
}).addValue({
name: 'qtd_doc_ex_com_deficiencia',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_com_deficiencia',
resultField: 'qtd_doc_ex_com_deficiencia',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_com_deficiencia'
}
}).addValue({
name: 'qtd_doc_ex_0_29',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_0_29',
resultField: 'qtd_doc_ex_0_29',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_0_29'
}
}).addValue({
name: 'qtd_doc_ex_30_34',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_30_34',
resultField: 'qtd_doc_ex_30_34',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_30_34'
}
}).addValue({
name: 'qtd_doc_ex_35_39',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_35_39',
resultField: 'qtd_doc_ex_35_39',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_35_39'
}
}).addValue({
name: 'qtd_doc_ex_40_44',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_40_44',
resultField: 'qtd_doc_ex_40_44',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_40_44'
}
}).addValue({
name: 'qtd_doc_ex_45_49',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_45_49',
resultField: 'qtd_doc_ex_45_49',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_45_49'
}
}).addValue({
name: 'qtd_doc_ex_50_54',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_50_54',
resultField: 'qtd_doc_ex_50_54',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_50_54'
}
}).addValue({
name: 'qtd_doc_ex_55_59',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_55_59',
resultField: 'qtd_doc_ex_55_59',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_55_59'
}
}).addValue({
name: 'qtd_doc_ex_60_mais',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_60_mais',
resultField: 'qtd_doc_ex_60_mais',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_60_mais'
}
}).addValue({
name: 'qtd_tec_total',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_total',
resultField: 'qtd_tec_total',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_total'
}
}).addValue({
name: 'qtd_tec_fundamental_incomp_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_fundamental_incomp_fem',
resultField: 'qtd_tec_fundamental_incomp_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_fundamental_incomp_fem'
}
}).addValue({
name: 'qtd_tec_fundamental_incomp_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_fundamental_incomp_masc',
resultField: 'qtd_tec_fundamental_incomp_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_fundamental_incomp_masc'
}
}).addValue({
name: 'qtd_tec_fundamental_comp_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_fundamental_comp_fem',
resultField: 'qtd_tec_fundamental_comp_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_fundamental_comp_fem'
}
}).addValue({
name: 'qtd_tec_fundamental_comp_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_fundamental_comp_masc',
resultField: 'qtd_tec_fundamental_comp_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_fundamental_comp_masc'
}
}).addValue({
name: 'qtd_tec_medio_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_medio_fem',
resultField: 'qtd_tec_medio_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_medio_fem'
}
}).addValue({
name: 'qtd_tec_medio_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_medio_masc',
resultField: 'qtd_tec_medio_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_medio_masc'
}
}).addValue({
name: 'qtd_tec_superior_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_superior_fem',
resultField: 'qtd_tec_superior_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_superior_fem'
}
}).addValue({
name: 'qtd_tec_superior_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_superior_masc',
resultField: 'qtd_tec_superior_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_superior_masc'
}
}).addValue({
name: 'qtd_tec_esp_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_esp_fem',
resultField: 'qtd_tec_esp_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_esp_fem'
}
}).addValue({
name: 'qtd_tec_esp_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_esp_masc',
resultField: 'qtd_tec_esp_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_esp_masc'
}
}).addValue({
name: 'qtd_tec_mestrado_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_mestrado_fem',
resultField: 'qtd_tec_mestrado_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_mestrado_fem'
}
}).addValue({
name: 'qtd_tec_mestrado_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_mestrado_masc',
resultField: 'qtd_tec_mestrado_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_mestrado_masc'
}
}).addValue({
name: 'qtd_tec_doutorado_fem',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_doutorado_fem',
resultField: 'qtd_tec_doutorado_fem',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_doutorado_fem'
}
}).addValue({
name: 'qtd_tec_doutorado_masc',
table: 'docente_ies_agregado',
tableField: 'qtd_tec_doutorado_masc',
resultField: 'qtd_tec_doutorado_masc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_tec_doutorado_mascc'
}
}).addValue({
name: 'qtd_doc_ex_bra',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_bra',
resultField: 'qtd_doc_ex_bra',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_bra'
}
}).addValue({
name: 'qtd_doc_ex_est',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_est',
resultField: 'qtd_doc_ex_est',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_est'
}
}).addValue({
name: 'tipo_org_acad',
table: 'docente_ies_agregado',
tableField: 'tipo_org_acad',
resultField: 'tipo_org_acad',
where: {
relation: '=',
type: 'integer',
field: 'tipo_org_acad'
}
}).addValue({
name: 'qtd_doc_ex_int',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_int',
resultField: 'qtd_doc_ex_int',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_int'
}
}).addValue({
name: 'qtd_doc_ex_de',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_de',
resultField: 'qtd_doc_ex_de',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_de'
}
}).addValue({
name: 'qtd_doc_ex_int_sem_de',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_int_sem_de',
resultField: 'qtd_doc_ex_int_sem_de',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_int_sem_de'
}
}).addValue({
name: 'qtd_doc_ex_parc',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_parc',
resultField: 'qtd_doc_ex_parc',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_parc'
}
}).addValue({
name: 'qtd_doc_ex_hor',
table: 'docente_ies_agregado',
tableField: 'qtd_doc_ex_hor',
resultField: 'qtd_doc_ex_hor',
where: {
relation: '=',
type: 'integer',
field: 'qtd_doc_ex_hor'
}
});
iesTeachers.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('docente_ies_agregado')
.field('sum(docente_ies_agregado.qtd_doc_exe)', 'total')
.field('docente_ies_agregado.ano_censo', 'year')
.field('docente_ies_agregado.cod_ies', 'university_id')
.field('docente_ies_agregado.nome_ies', 'university_name')
.group('docente_ies_agregado.ano_censo')
.group('docente_ies_agregado.cod_ies')
.group('docente_ies_agregado.nome_ies')
.order('docente_ies_agregado.ano_censo')
console.log(req.sql.toString())
next();
}, query, id2str.transform(false), response('docente_ies_agregado'));
module.exports = iesTeachers;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment