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
Harbor Registry
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
7ffb645e
Commit
7ffb645e
authored
2 weeks ago
by
tgcl21
Browse files
Options
Downloads
Patches
Plain Diff
Updated calculus
parent
53c12859
Branches
enrollment_rate
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes_v1/enrollmentRate.js
+49
-28
49 additions, 28 deletions
src/libs/routes_v1/enrollmentRate.js
with
49 additions
and
28 deletions
src/libs/routes_v1/enrollmentRate.js
+
49
−
28
View file @
7ffb645e
...
...
@@ -255,6 +255,7 @@ rqf.addField({
})
function
matchQueries
(
queryPartial
,
queryTotal
)
{
let
match
=
[];
...
...
@@ -279,12 +280,6 @@ function matchQueries(queryPartial, queryTotal) {
const
modality
=
modalityMap
[
ageRange
];
const
partialValue
=
escolaData
[
modality
.
field
]
||
0
;
console
.
log
(
'
Partial Value:
'
,
partialValue
);
console
.
log
(
'
Total Value:
'
,
pnad
.
total
);
console
.
log
(
'
Year:
'
,
pnad
.
year
);
console
.
log
(
'
Age Range:
'
,
ageRange
);
console
.
log
(
'
Modality:
'
,
modality
.
name
);
console
.
log
(
'
Modality ID:
'
,
modality
.
id
);
match
.
push
({
year
:
pnad
.
year
,
...
...
@@ -293,6 +288,14 @@ function matchQueries(queryPartial, queryTotal) {
attended_modality_id
:
modality
.
id
,
attended_modality_name
:
modality
.
name
,
total
:
((
partialValue
/
pnad
.
total
)
*
100
).
toFixed
(
2
),
location_id
:
pnad
.
location_id
,
location_name
:
id2str
.
location
(
pnad
.
location_id
),
cod_cap_id
:
pnad
.
capital_id
,
cod_cap_name
:
id2str
.
capitalCode
(
pnad
.
capital_id
),
region_id
:
pnad
.
region_id
,
region_name
:
id2str
.
regionCode
(
pnad
.
region_id
),
state_id
:
pnad
.
state_id
,
state_name
:
id2str
.
stateName
(
pnad
.
state_id
),
});
}
else
{
match
.
push
({
...
...
@@ -313,20 +316,31 @@ EnrollmentRateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req
.
querySet
=
[];
let
whereCondition
=
""
;
let
filterId
;
const
filters
=
req
.
query
.
filter
.
split
(
"
,
"
);
filters
.
forEach
((
filter
)
=>
{
if
(
filter
.
includes
(
"
min_year
"
))
{
filterId
=
filter
.
split
(
"
:
"
)[
1
];
whereCondition
+=
`pnad_novo.ano_ref >=
${
filterId
}
`
;
}
if
(
filter
.
includes
(
"
max_year
"
))
{
filterId
=
filter
.
split
(
"
:
"
)[
1
];
whereCondition
+=
`pnad_novo.ano_ref <=
${
filterId
}
`
;
}
})
// let whereCondition = "";
// let filterId;
// const filters = req.query.filter.split(",");
// filters.forEach((filter) => {
// if (filter.includes("min_year")) {
// filterId = filter.split(":")[1];
// whereCondition += `pnad_novo.ano_ref >= ${filterId}`;
// }
// if (filter.includes("max_year")) {
// filterId = filter.split(":")[1];
// whereCondition += `pnad_novo.ano_ref <= ${filterId}`;
// }
// if (filter.includes("location")) {
// filterId = filter.split(":")[1];
// whereCondition += `pnad_novo.situacao_domicilio = ${filterId}`;
// }
// if (filter.includes("cod_cap")) {
// filterId = filter.split(":")[1];
// whereCondition += `pnad_novo.cod_cap = ${filterId}`;
// }
// if (filter.includes("state")) {
// filterId = filter.split(":")[1];
// whereCondition += `pnad_novo.region = ${filterId}`;
// }
// })
// let query_escola = req.sql.clone();
...
...
@@ -350,10 +364,14 @@ EnrollmentRateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
sum(escola.qt_mat_fund_ai)
'
,
'
total_fund_ai
'
)
.
field
(
'
sum(escola.qt_mat_fund_af)
'
,
'
total_fund_af
'
)
.
field
(
'
sum(escola.qt_mat_med)
'
,
'
total_med
'
)
.
field
(
'
escola.localizacao_id
'
,
'
location_id
'
)
.
field
(
'
escola.regiao_id
'
,
'
region_id
'
)
.
where
(
'
escola.situacao_funcionamento_pareada = 1
'
)
.
where
(
'
(escola.ensino_regular = 1 or escola.ensino_eja = 1 or escola.educacao_profissional = 1)
'
)
.
where
(
'
escola.ano_censo IN (2019, 2022, 2023)
'
)
.
group
(
'
escola.ano_censo
'
);
.
group
(
'
escola.localizacao_id
'
)
.
group
(
'
escola.ano_censo
'
)
.
group
(
'
escola.regiao_id
'
);
req
.
querySet
.
push
(
query_escola
);
let
query_pnad
=
req
.
sql
.
clone
();
...
...
@@ -361,12 +379,20 @@ EnrollmentRateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)
'
,
'
total
'
)
.
field
(
'
pnad_novo.faixa_etaria
'
,
'
age_range
'
)
.
field
(
'
pnad_novo.ano_ref
'
,
'
year
'
)
.
field
(
'
pnad_novo.situacao_domicilio
'
,
'
location_id
'
)
.
field
(
'
pnad_novo.cod_cap
'
,
'
capital_id
'
)
.
field
(
'
pnad_novo.cod_regiao
'
,
'
region_id
'
)
.
field
(
'
pnad_novo.cod_uf
'
,
'
state_id
'
)
.
where
(
'
pnad_novo.ano_ref IN (2019, 2022, 2023) AND pnad_novo.faixa_etaria IN (1, 2, 3, 4, 5)
'
)
.
where
(
whereCondition
)
.
group
(
'
pnad_novo.ano_ref
'
)
.
group
(
'
pnad_novo.faixa_etaria
'
)
.
group
(
'
pnad_novo.situacao_domicilio
'
)
.
group
(
'
pnad_novo.cod_cap
'
)
.
group
(
'
pnad_novo.cod_regiao
'
)
.
group
(
'
pnad_novo.cod_uf
'
)
.
order
(
'
pnad_novo.ano_ref
'
)
.
order
(
'
pnad_novo.faixa_etaria
'
);
req
.
querySet
.
push
(
query_pnad
);
// let query_pnad = squel.select()
...
...
@@ -381,11 +407,6 @@ EnrollmentRateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
// .order('pnad_novo.ano_ref')
// .order('pnad_novo.faixa_etaria');
console
.
log
(
query_escola
.
toString
())
console
.
log
(
query_pnad
.
toString
())
// req.querySet.push(query_escola);
// req.querySet.push(query_pnad);
next
();
},
multiQuery
,
(
req
,
res
,
next
)
=>
{
...
...
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