Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • simcaq/simcaq-node
  • SMPPIR/SMPPIR-Node
2 results
Show changes
Commits on Source (7)
...@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License ...@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/ */
module.exports = function ageRange(id) { module.exports = function ageRangeAll(id) {
switch (id) { switch (id) {
case 1: case 1:
return '0 a 3 anos'; return '0 a 3 anos';
......
...@@ -111,7 +111,7 @@ superiorEducationConclusionTaxApp.get('/region', (req, res, next) => { ...@@ -111,7 +111,7 @@ superiorEducationConclusionTaxApp.get('/region', (req, res, next) => {
next(); next();
}, response('region')); }, response('region'));
superiorEducationConclusionTaxApp.get('/cap_code', (req, res, next) => { superiorEducationConclusionTaxApp.get('/cap_code_pnad', (req, res, next) => {
req.result = [] req.result = []
for (let i = 11; i < 54; i++) { for (let i = 11; i < 54; i++) {
if (id2str.capitalCode(i) !== 'Não informado') { if (id2str.capitalCode(i) !== 'Não informado') {
...@@ -120,10 +120,8 @@ superiorEducationConclusionTaxApp.get('/cap_code', (req, res, next) => { ...@@ -120,10 +120,8 @@ superiorEducationConclusionTaxApp.get('/cap_code', (req, res, next) => {
}); });
} }
} }
req.result.push({id: 99, name: id2str.capitalCode(99)});
next(); next();
}, response('cap_code')); }, response('cap_code_pnad'));
superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => { superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => {
req.result = [] req.result = []
...@@ -134,7 +132,6 @@ superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => { ...@@ -134,7 +132,6 @@ superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => {
}); });
} }
} }
req.result.push({id: 99, name: id2str.metroCode(99)});
next(); next();
}, response('metro_code')); }, response('metro_code'));
...@@ -160,6 +157,7 @@ superiorEducationConclusionTaxApp.get('/income_range', (req, res, next) => { ...@@ -160,6 +157,7 @@ superiorEducationConclusionTaxApp.get('/income_range', (req, res, next) => {
}); });
} }
req.result.push({id: 10, name: id2str.incomeRange(10)}); req.result.push({id: 10, name: id2str.incomeRange(10)});
next(); next();
}, response('income_range')); }, response('income_range'));
...@@ -242,16 +240,17 @@ superiorEducationConclusionTaxApp.get('/state', (req, res, next) => { ...@@ -242,16 +240,17 @@ superiorEducationConclusionTaxApp.get('/state', (req, res, next) => {
next(); next();
}, response('state')); }, response('state'));
superiorEducationConclusionTaxApp.get('/age_range', (req, res, next) => { superiorEducationConclusionTaxApp.get('/age_range_all', (req, res, next) => {
req.result = [] req.result = []
for (let i = 1; i < 12; i++) { for (let i = 7; i < 12; i++) {
req.result.push({ req.result.push({
id: i, name: id2str.ageRangeAll(i) id: i, name: id2str.ageRangeAll(i)
}); });
} }
console.log(req.result);
next(); next();
}, response('age_range')); }, response('age_range_all'));
superiorEducationConclusionTaxApp.get('/location', (req, res, next) => { superiorEducationConclusionTaxApp.get('/location', (req, res, next) => {
req.result = [] req.result = []
...@@ -444,10 +443,10 @@ rqf.addField({ ...@@ -444,10 +443,10 @@ rqf.addField({
field: 'sexo' field: 'sexo'
} }
}).addValue({ }).addValue({
name: 'cap_code', name: 'cap_code_pnad',
table: 'pnad_novo', table: 'pnad_novo',
tableField: 'cod_cap', tableField: 'cod_cap',
resultField: 'cap_code_id', resultField: 'cap_code_pnad_id',
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
...@@ -575,9 +574,28 @@ function matchQueries(queryPartial, queryTotal) { ...@@ -575,9 +574,28 @@ function matchQueries(queryPartial, queryTotal) {
return match; return match;
} }
function whereCondition(req) {
let where = "";
let filterId;
//const filters = req.query.filter.split(",");
const dims = req.query.dims;
if (dims && dims.includes("cap_code_pnad")){
where += `pnad_novo.cod_cap <> 99`;
}
if (dims && dims.includes("income_range")){
where += `pnad_novo.faixa_rendimento_aux_tx is not null`;
}
if (dims && dims.includes("age_range_superior")){
where += `pnad_novo.faixa_etaria > 6`;
}
return where;
}
superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.querySet = []; req.querySet = [];
let where = whereCondition(req);
// Subquery para total_pop_maior_25 com filtros dinâmicos // Subquery para total_pop_maior_25 com filtros dinâmicos
let totalPopMaior25ComSuperiorCompleto = req.sql.clone(); let totalPopMaior25ComSuperiorCompleto = req.sql.clone();
totalPopMaior25ComSuperiorCompleto.from("pnad_novo") totalPopMaior25ComSuperiorCompleto.from("pnad_novo")
...@@ -586,9 +604,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, ...@@ -586,9 +604,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res,
.where("idade_morador_31_03 >= 25") .where("idade_morador_31_03 >= 25")
.where("nivel_de_instruc_mais_elevad_para_o_fundam_com_duracao_9_anos = 7") .where("nivel_de_instruc_mais_elevad_para_o_fundam_com_duracao_9_anos = 7")
.where("ano_ref >= 2019") .where("ano_ref >= 2019")
.where(`${where}`)
.group("ano_ref") .group("ano_ref")
.order("ano_ref"); .order("ano_ref");
// Subquery para total_pop_maior_25 com filtros dinâmicos // Subquery para total_pop_maior_25 com filtros dinâmicos
let totalPopMaior25 = req.sql.clone(); let totalPopMaior25 = req.sql.clone();
...@@ -597,14 +616,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, ...@@ -597,14 +616,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res,
.field("SUM(peso_domicilio_pessoas_com_cal)", "total") .field("SUM(peso_domicilio_pessoas_com_cal)", "total")
.where("idade_morador_31_03 >= 25") .where("idade_morador_31_03 >= 25")
.where("ano_ref >= 2019") .where("ano_ref >= 2019")
.where(`${where}`)
.group("ano_ref") .group("ano_ref")
.order("ano_ref"); .order("ano_ref");
// if (req.query.dims && req.query.dims.includes("income_range")) {
// totalPopMaior19.where("faixa_rendimento_aux_tx is not null");
// totalPopEdBasMaior19.where("faixa_rendimento_aux_tx is not null");
// }
req.querySet.push(totalPopMaior25ComSuperiorCompleto); req.querySet.push(totalPopMaior25ComSuperiorCompleto);
req.querySet.push(totalPopMaior25); req.querySet.push(totalPopMaior25);
......