Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
cae2bd90
Commit
cae2bd90
authored
5 months ago
by
es23
Browse files
Options
Downloads
Patches
Plain Diff
dimensions qtd_graduates
parent
a443dd6a
No related branches found
No related tags found
2 merge requests
!502
Development
,
!492
Indicador Número de Matrículas do Ensino Superior (novo)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes_v1/superiorEnrollmentAggregate.js
+112
-271
112 additions, 271 deletions
src/libs/routes_v1/superiorEnrollmentAggregate.js
with
112 additions
and
271 deletions
src/libs/routes_v1/superiorEnrollmentAggregate.js
+
112
−
271
View file @
cae2bd90
...
@@ -52,193 +52,80 @@ superiorEnrollmentAggregateApp.use(cache('15 day'));
...
@@ -52,193 +52,80 @@ superiorEnrollmentAggregateApp.use(cache('15 day'));
let
rqf
=
new
ReqQueryFields
();
let
rqf
=
new
ReqQueryFields
();
// superiorEnrollmentAggregateApp.get('/years', (req, res, next) => {
superiorEnrollmentAggregateApp
.
get
(
'
/years
'
,
(
req
,
res
,
next
)
=>
{
// req.sql.from('escola')
req
.
sql
.
from
(
'
curso_superior_agregado
'
)
// .field('DISTINCT escola.ano_censo', 'year')
.
field
(
'
DISTINCT curso_superior_agregado.ano_censo
'
,
'
year
'
)
// .where('escola.ano_censo >= 2021')
.
where
(
'
curso_superior_agregado.ano_censo >= 2020
'
)
// next();
next
();
// }, query, response('years'));
},
query
,
response
(
'
years
'
));
// superiorEnrollmentAggregateApp.get('/adm_dependency', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 5; i++) {
// req.result.push({
// id: i, name: id2str.admDependency(i)
// });
// }
// next();
// }, response('adm_dependency'));
// superiorEnrollmentAggregateApp.get('/adm_dependency_detailed', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 8; i++) {
// req.result.push({
// id: i, name: id2str.admDependencyPriv(i)
// });
// }
// next();
// }, response('adm_dependency_detailed'));
// superiorEnrollmentAggregateApp.get('/government_agreement', (req, res, next) => {
// req.result = []
// for(let i = 1; i <= 6; ++i) {
// req.result.push({
// id: i,
// name: id2str.governmentAgreement(i)
// });
// };
// next();
// }, response('government_agreement'));
// superiorEnrollmentAggregateApp.get('/education_level_mod_agg', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 13; i++) {
// req.result.push({
// id: i, name: id2str.educationLevelMod(i)
// });
// }
// next();
// }, response('education_level_mod_agg'));
// superiorEnrollmentAggregateApp.get('/integral_time_agg', (req, res, next) => {
// req.result = []
// for (let i = 0; i <= 3; i++) {
// req.result.push({
// id: i, name: id2str.integralTime(i)
// });
// }
// next();
// }, response('integral_time_agg'));
// superiorEnrollmentAggregateApp.get('/location', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 2; i++) {
// req.result.push({
// id: i, name: id2str.location(i)
// });
// }
// next();
// }, response('location'));
// superiorEnrollmentAggregateApp.get('/diff_location', (req, res, next) => {
// req.result = []
// for (let i = 0; i < 4; i++) {
// req.result.push({
// id: i, name: id2str.diffLocation(i)
// });
// }
// req.result.push({
// id: 8, name: 'Área onde se localizam povos e comunidades tradicionais'
// })
// next();
// }, response('diff_location'));
// superiorEnrollmentAggregateApp.get('/modality_integral_time', (req, res, next) => {
// req.result = []
// for (let i = 0; i <= 7; i++) {
// req.result.push({
// id: i, name: id2str.educationLevelBasic(i)
// });
// }
// next();
// }, response('modality_integral_time'));
// superiorEnrollmentAggregateApp.get('/gender', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 2; i++) {
// req.result.push({
// id: i, name: id2str.gender(i)
// });
// }
// next();
// }, response('gender'));
// superiorEnrollmentAggregateApp.get('/age_range', (req, res, next) => {
// req.result = []
// for (let i = 1; i <= 7; i++) {
// req.result.push({
// id: i, name: id2str.ageRangeAggregate(i)
// });
// }
// next();
// }, response('age_range'));
// superiorEnrollmentAggregateApp.get('/ethnic_group', (req, res, next) => {
// req.result = []
// for (let i = 0; i <= 6; i++) {
// req.result.push({
// id: i, name: id2str.ethnicGroup(i)
// });
// }
// next();
// }, response('ethnic_group'));
// superiorEnrollmentAggregateApp.get('/period_agg', (req, res, next) => {
// req.result = []
// for (let i = 0; i <= 5; i++) {
// req.result.push({
// id: i, name: id2str.period(i)
// });
// }
// next();
// }, response('period_agg'));
// superiorEnrollmentAggregateApp.get('/region', (req, res, next) => {
// req.result = []
// for (let i = 0; i <= 5; i++) {
// req.result.push({
// id: i, name: id2str.regionCode(i)
// });
// }
// next();
// }, response('period_agg'));
// superiorEnrollmentAggregateApp.get('/state', (req, res, next) => {
// req.result = []
// for (let i = 11; i < 54; i++) {
// if (id2str.stateName(i) !== 'Não declarada') {
// req.result.push({
// id: i, name: id2str.stateName(i)
// });
// }
// }
// next();
// }, response('state'));
// superiorEnrollmentAggregateApp.get('/special_education', (req, res, next) => {
superiorEnrollmentAggregateApp
.
get
(
'
/qtd_graduates
'
,
(
req
,
res
,
next
)
=>
{
// req.result = []
req
.
sql
.
from
(
'
curso_superior_agregado
'
)
.
field
(
'
DISTINCT SUM(curso_superior_agregado.qtd_concluintes)
'
,
'
qtd_graduates
'
)
.
where
(
'
curso_superior_agregado.ano_censo >= 2020
'
)
next
();
// for (let i = 1; i <= 2; i++) {
})
// req.result.push({
// id: i, name: id2str.specialEducation(i)
// });
// }
// next();
superiorEnrollmentAggregateApp
.
get
(
'
/tp_categ_adm
'
,
(
req
,
res
,
next
)
=>
{
// }, response('special_education'));
req
.
result
=
[]
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
admDependency
(
i
)
});
}
next
();
},
response
(
'
adm_dependency
'
));
superiorEnrollmentAggregateApp
.
get
(
'
/cine_global
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
0
;
i
<=
10
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
cineGeral
(
i
)
});
};
next
();
},
response
(
'
cine_global
'
));
superiorEnrollmentAggregateApp
.
get
(
'
/cine_specific
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
const
defaultCase
=
null
;
for
(
let
i
=
0
;
i
<=
104
;
++
i
)
{
let
obj
=
{
id
:
i
,
name
:
id2str
.
cineSpecific
(
i
)
};
if
(
obj
.
name
!==
id1str
.
cineSpecific
(
defaultCase
)){
req
.
result
.
push
(
obj
);
}
};
req
.
result
.
push
({
id
:
defaultCase
,
name
:
id2str
.
cineSpecific
(
defaultCase
)
});
next
();
},
response
(
'
cine_specific
'
));
superiorEnrollmentAggregateApp
.
get
(
'
/cine_detailed
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
const
defaultCase
=
null
;
for
(
let
i
=
11
;
i
<=
1041
;
++
i
)
{
let
obj
=
{
id
:
i
,
name
:
id2str
.
cineDetailed
(
i
)
};
if
(
obj
.
name
!==
id2str
.
cineDetailed
(
defaultCase
)){
req
.
result
.
push
(
obj
);
}
};
req
.
result
.
push
({
id
:
defaultCase
,
name
:
id2str
.
cineDetailed
(
defaultCase
)
});
next
();
},
response
(
'
cine_detailed
'
));
rqf
.
addField
({
rqf
.
addField
({
name
:
'
filter
'
,
name
:
'
filter
'
,
...
@@ -373,58 +260,45 @@ rqf.addField({
...
@@ -373,58 +260,45 @@ rqf.addField({
type
:
'
integer
'
,
type
:
'
integer
'
,
field
:
'
tp_org_acad
'
field
:
'
tp_org_acad
'
}
}
});
}).
addValue
({
name
:
'
region_agg
'
,
function
matchQueries
(
queryPartial
,
queryTotal
)
{
table
:
'
curso_superior_agregado
'
,
let
match
=
[];
tableField
:
'
nome_reg
'
,
queryTotal
.
forEach
((
result
)
=>
{
resultField
:
'
reg_name
'
,
let
newObj
=
{};
where
:
{
let
keys
=
Object
.
keys
(
result
);
relation
:
'
=
'
,
keys
.
forEach
((
key
)
=>
{
type
:
'
integer
'
,
newObj
[
key
]
=
result
[
key
];
field
:
'
cod_reg
'
});
let
index
=
keys
.
indexOf
(
'
cod
'
);
if
(
index
>
-
1
)
keys
.
splice
(
index
,
1
);
let
objMatch
=
null
;
for
(
let
i
=
0
;
i
<
queryPartial
.
length
;
++
i
)
{
let
partial
=
queryPartial
[
i
];
let
foundMatch
=
true
;
for
(
let
j
=
0
;
j
<
keys
.
length
;
++
j
)
{
let
key
=
keys
[
j
];
if
(
partial
[
key
]
!==
result
[
key
])
{
foundMatch
=
false
;
break
;
}
}
if
(
foundMatch
)
{
objMatch
=
partial
;
break
;
}
}
}).
addValue
({
name
:
'
uf_agg
'
,
table
:
'
curso_superior_agregado
'
,
tableField
:
'
nome_uf
'
,
resultField
:
'
uf_name
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
cod_uf
'
}
}
}).
addValue
({
if
(
objMatch
)
{
name
:
'
mun_agg
'
,
newObj
.
denominator
=
result
.
cod
;
table
:
'
curso_superior_agregado
'
,
newObj
.
partial
=
objMatch
.
cod
;
tableField
:
'
nome_mun
'
,
// newObj.total = (objMatch.total / result.total) * 100;
resultField
:
'
mun_name
'
,
match
.
push
(
newObj
);
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
cod_mun
'
}
}
})
;
})
return
match
;
}
superiorEnrollmentAggregateApp
.
get
(
'
/
'
,
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
superiorEnrollmentAggregateApp
.
get
(
'
/
'
,
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
req
.
querySet
=
[];
let
basic
=
req
.
sql
.
clone
();
let
curso
=
req
.
sql
.
clone
();
let
ies
=
req
.
sql
.
clone
();
basic
.
field
(
'
curso_superior_agregado.ano_censo
'
,
'
year
'
);
req
.
sql
.
field
(
'
curso_superior_agregado.ano_censo
'
,
'
year
'
);
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
ethnic_group
"
)){
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
ethnic_group
"
)){
basic
.
field
.
field
(
'
sum(qtd_mat_branca)
'
,
'
total_branca
'
)
req
.
sql
.
field
.
field
(
'
sum(qtd_mat_branca)
'
,
'
total_branca
'
)
.
field
(
'
sum(qtd_mat_preta)
'
,
'
total_preta
'
)
.
field
(
'
sum(qtd_mat_preta)
'
,
'
total_preta
'
)
.
field
(
'
sum(qtd_mat_parda)
'
,
'
total_parda
'
)
.
field
(
'
sum(qtd_mat_parda)
'
,
'
total_parda
'
)
.
field
(
'
sum(qtd_mat_amarela)
'
,
'
total_amarela
'
)
.
field
(
'
sum(qtd_mat_amarela)
'
,
'
total_amarela
'
)
...
@@ -432,12 +306,12 @@ superiorEnrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, nex
...
@@ -432,12 +306,12 @@ superiorEnrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, nex
.
field
(
'
sum(qtd_mat_cor_nao_declarada)
'
,
'
total_nd
'
);
.
field
(
'
sum(qtd_mat_cor_nao_declarada)
'
,
'
total_nd
'
);
}
}
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
school_type
"
)){
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
school_type
"
)){
basic
.
field
(
'
sum(qtd_mat_proces_publica)
'
,
'
total_publica
'
)
req
.
sql
.
field
(
'
sum(qtd_mat_proces_publica)
'
,
'
total_publica
'
)
.
field
(
'
sum(qtd_mat_proces_privada)
'
,
'
total_privada
'
)
.
field
(
'
sum(qtd_mat_proces_privada)
'
,
'
total_privada
'
)
.
field
(
'
sum(qtd_mat_proces_nao_informada)
'
,
'
total_nao_informada
'
);
.
field
(
'
sum(qtd_mat_proces_nao_informada)
'
,
'
total_nao_informada
'
);
}
}
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
age_range_cescu
"
)){
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
age_range_cescu
"
)){
basic
.
field
(
'
sum(qtd_mat_0_17)
'
,
'
total_0_17
'
)
req
.
sql
.
field
(
'
sum(qtd_mat_0_17)
'
,
'
total_0_17
'
)
.
field
(
'
sum(qtd_mat_18_24)
'
,
'
total_18_24
'
)
.
field
(
'
sum(qtd_mat_18_24)
'
,
'
total_18_24
'
)
.
field
(
'
sum(qtd_mat_25_29)
'
,
'
total_25_29
'
)
.
field
(
'
sum(qtd_mat_25_29)
'
,
'
total_25_29
'
)
.
field
(
'
sum(qtd_mat_30_34)
'
,
'
total_30_34
'
)
.
field
(
'
sum(qtd_mat_30_34)
'
,
'
total_30_34
'
)
...
@@ -447,59 +321,26 @@ superiorEnrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, nex
...
@@ -447,59 +321,26 @@ superiorEnrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, nex
.
field
(
'
sum(qtd_mat_60_mais)
'
,
'
total_60_mais
'
);
.
field
(
'
sum(qtd_mat_60_mais)
'
,
'
total_60_mais
'
);
}
}
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
gender
"
)){
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
gender
"
)){
basic
.
field
(
'
sum(qtd_mat_fem)
'
,
'
total_fem
'
)
req
.
sql
.
field
(
'
sum(qtd_mat_fem)
'
,
'
total_fem
'
)
.
field
(
'
sum(qtd_mat_masc)
'
,
'
total_masc
'
);
.
field
(
'
sum(qtd_mat_masc)
'
,
'
total_masc
'
);
}
}
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
modality_shift_superior
"
)){
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
modality_shift_superior
"
)){
basic
.
field
(
'
sum(qtd_mat_diurno)
'
,
'
total_diurno
'
)
req
.
sql
.
field
(
'
sum(qtd_mat_diurno)
'
,
'
total_diurno
'
)
.
field
(
'
sum(qtd_mat_noturno)
'
,
'
total_noturno
'
);
.
field
(
'
sum(qtd_mat_noturno)
'
,
'
total_noturno
'
);
}
}
else
if
(
req
.
query
.
dims
&&
req
.
query
.
dims
.
includes
(
"
region
"
)){
curso
.
field
(
'
qtd_matriculas
'
,
'
enrollment
'
)
curso
.
field
(
'
cod_reg
'
,
'
cod
'
)
curso
.
field
(
'
nome_reg
'
,
'
cod_name
'
)
.
where
(
'
tp_nivel_acad = 1
'
)
.
from
(
'
curso_superior_agregado
'
)
.
group
(
'
ano_censo
'
)
.
order
(
'
ano_censo
'
);
ies
.
field
(
'
nome_regiao_ies
'
,
'
cod_name
'
)
.
where
(
'
tp_nivel_acad = 1
'
)
.
from
(
'
ies_ens_superior
'
)
.
where
(
'
ano_censo > 2019
'
)
.
group
(
'
ano_censo
'
)
.
order
(
'
ano_censo
'
);
}
else
{
else
{
basic
.
field
(
'
SUM(qtd_matriculas)
'
,
'
enrollment
'
);
req
.
sql
.
field
(
'
SUM(qtd_matriculas)
'
,
'
enrollment
'
);
}
}
basic
.
from
(
'
curso_superior_agregado
'
)
req
.
sql
.
from
(
'
curso_superior_agregado
'
)
.
from
(
'
ies_ens_superior
'
)
// .join('ies_ens_superior', null, 'ies_ens_superior.ano_censo = curso_superior_agregado.ano_censo')
.
where
(
'
tp_nivel_acad = 1
'
)
.
where
(
'
tp_nivel_acad = 1
'
)
.
group
(
'
curso_superior_agregado.ano_censo
'
)
.
group
(
'
curso_superior_agregado.ano_censo
'
)
.
order
(
'
curso_superior_agregado.ano_censo
'
);
.
order
(
'
curso_superior_agregado.ano_censo
'
);
// console.log(req.sql.toString());
// // console.log(req.query.dims);
// console.log(req.sql.result);
req
.
querySet
.
push
(
basic
);
console
.
log
(
req
.
sql
.
toString
());
req
.
querySet
.
push
(
curso
);
req
.
querySet
.
push
(
ies
);
next
();
next
();
},
multiQuery
,
query
,
aggregateData
,
id2str
.
transform
(
false
),
response
(
'
superior_enrollment_aggregate
'
),
(
req
,
res
,
next
)
=>
{
},
multiQuery
,
query
,
aggregateData
,
id2str
.
transform
(
false
),
response
(
'
superior_enrollment_aggregate
'
));
if
(
req
.
result
[
1
]
||
req
.
result
[
2
]){
let
newObj
=
matchQueries
(
req
.
result
[
1
],
req
.
result
[
2
]);
req
.
result
=
newObj
;
}
else
{
req
.
result
=
req
.
result
[
0
];
}
next
();
});
module
.
exports
=
superiorEnrollmentAggregateApp
;
module
.
exports
=
superiorEnrollmentAggregateApp
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment