Skip to content
Snippets Groups Projects
Commit 80f3da87 authored by Edu Trevisan's avatar Edu Trevisan
Browse files

Sim

parent 8f8f35ec
No related branches found
No related tags found
1 merge request!28Development
/*
Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of SMPPIR-Node.
SMPPIR-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.
SMPPIR-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 SMPPIR-Node. If not, see <https://www.gnu.org/licenses/>.
*/
const express = require('express');
const router = 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 rqf = new ReqQueryFields();
rqf.addField({
name: 'filter',
field: false,
where: true,
}).addField({
name: 'dims',
field: true,
where: false,
})
.addValue({
name: 'year',
table: 'sim',
tableField: 'ano_obito',
resultField: 'ano',
where: {
relation: '=',
type: 'integer',
field: 'ano_obito',
},
})
.addValue({
name: 'uf',
table: 'sim',
tableField: '"ocor_SIGLA_UF"',
resultField: 'uf',
where: {
relation: '=',
type: 'string',
field: '"ocor_SIGLA_UF"',
},
})
.addValue({
name: 'def_raca_cor',
table: 'sim',
tableField: 'def_raca_cor',
resultField: 'def_raca_cor',
where: {
relation: '=',
type: 'string',
field: 'def_raca_cor',
},
})
.addValue({
name: 'raca_cor',
table: 'sim',
tableField: '"RACACOR"',
resultField: 'raca_cor',
where: {
relation: '=',
type: 'integer',
field: 'RACACOR',
},
})
.addValue({
name: 'def_tipo_obito',
table: 'sim',
tableField: 'def_circ_obito',
resultField: 'def_tipo_obito',
where: {
relation: '=',
type: 'integer',
field: 'def_circ_obito',
},
})
.addValue({
name: 'tipo_obito',
table: 'sim',
tableField: '"CIRCOBITO"',
resultField: 'tipo_obito',
where: {
relation: '=',
type: 'integer',
field: '"CIRCOBITO"',
},
})
.addValue({
name: 'min_idade',
table: 'sim',
tableField: 'idade_obito_anos',
resultField: 'idade',
where: {
relation: '>=',
type: 'integer',
field: 'idade_obito_anos',
},
})
.addValue({
name: 'max_idade',
table: 'sim',
tableField: 'idade_obito_anos',
resultField: 'idade',
where: {
relation: '<=',
type: 'integer',
field: 'idade_obito_anos',
},
})
.addValue({
name: 'sexo',
table: 'sim',
tableField: '"SEXO"',
resultField: 'sexo',
where: {
relation: '=',
type: 'integer',
field: '"SEXO"',
},
})
.addValue({
name: 'def_sexo',
table: 'sim',
tableField: 'def_sexo',
resultField: 'def_sexo',
where: {
relation: '=',
type: 'string',
field: 'def_sexo',
},
})
router.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
console.log(req.sql.toString());
req.sql.field('count(*) AS Total')
.from('sim');
next();
}, query, response('sim'));
module.exports = router;
/*
Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of SMPPIR-Node.
SMPPIR-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.
SMPPIR-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 SMPPIR-Node. If not, see <https://www.gnu.org/licenses/>.
*/
const express = require('express');
const router = 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 rqf = new ReqQueryFields();
rqf.addField({
name: 'filter',
field: false,
where: true,
}).addField({
name: 'dims',
field: true,
where: false,
})
.addValue({
name: 'year',
table: 'taxa_homicidios',
tableField: 'ano',
resultField: 'ano',
where: {
relation: '=',
type: 'integer',
field: 'ano',
},
})
.addValue({
name: 'uf',
table: 'taxa_homicidios',
tableField: 'uf',
resultField: 'uf',
where: {
relation: '=',
type: 'string',
field: 'uf',
},
})
.addValue({
name: 'raca_cor',
table: 'taxa_homicidios',
tableField: 'raca_cor',
resultField: 'raca_cor',
where: {
relation: '=',
type: 'string',
field: 'raca_cor',
},
})
router.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
console.log(req.sql.toString());
req.sql.field(
'cast(cast(sum(obito) as float)*100000/cast(sum(filtro_ibge) as float) as integer) as taxa'
)
.from('taxa_homicidios');
next();
}, query, response('taxa_homicidios'));
module.exports = router;
......@@ -92,6 +92,9 @@ const youth_jobs = require(`${libs}/routes/SMPPIR/youth_jobs`)
const youth_education = require(`${libs}/routes/SMPPIR/youth_education`)
const sim = require(`${libs}/routes/SMPPIR/sim`)
const taxa_homicidios = require(`${libs}/routes/SMPPIR/taxa_homicidios`)
const universityEnrollment = require(`${libs}/routes/universityEnrollment`);
......@@ -139,5 +142,7 @@ api.use('/ciganos_culture', ciganos_culture);
api.use('/ciganos_sustentability', ciganos_sustentability);
api.use('/youth_jobs', youth_jobs)
api.use('/youth_education', youth_education)
api.use('/sim', sim)
api.use('/taxa_homicidios', taxa_homicidios)
module.exports = api;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment