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
b5d902fe
There was a problem fetching the pipeline summary.
Commit
b5d902fe
authored
6 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
First prototype of classroom count route
parent
b6916c1e
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes/classroomCount.js
+78
-20
78 additions, 20 deletions
src/libs/routes/classroomCount.js
with
78 additions
and
20 deletions
src/libs/routes/classroomCount.js
+
78
−
20
View file @
b5d902fe
...
@@ -202,13 +202,14 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
...
@@ -202,13 +202,14 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
.
group
(
'
escola.ano_censo
'
)
.
group
(
'
escola.ano_censo
'
)
.
order
(
'
escola.ano_censo
'
)
.
order
(
'
escola.ano_censo
'
)
.
where
(
'
escola.situacao_de_funcionamento = 1 AND escola.local_func_predio_escolar = 1
'
);
.
where
(
'
escola.situacao_de_funcionamento = 1 AND escola.local_func_predio_escolar = 1
'
);
next
();
next
();
},
rqf
.
build
(),
query
,
id2str
.
transform
(),
(
req
,
res
,
next
)
=>
{
},
rqf
.
build
(),
query
,
id2str
.
transform
(),
(
req
,
res
,
next
)
=>
{
let
classSize
=
JSON
.
parse
(
req
.
body
.
class_size
)
||
null
;
let
classSize
=
JSON
.
parse
(
req
.
body
.
class_size
)
||
null
;
let
integralTime
=
JSON
.
parse
(
req
.
body
.
integral_time
)
||
null
;
let
integralTime
=
JSON
.
parse
(
req
.
body
.
integral_time
)
||
null
;
console
.
log
(
classSize
,
integralTime
);
//
console.log(classSize, integralTime);
req
.
classroom
=
req
.
result
;
req
.
classroom
=
req
.
result
;
let
classroom
=
[];
let
classroom
=
[];
...
@@ -240,29 +241,86 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
...
@@ -240,29 +241,86 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
});
});
let
result
=
[];
let
result
=
[];
// Para cada resultado
classroom
.
forEach
((
c
)
=>
{
classroom
.
forEach
((
c
)
=>
{
function
filterUrbanEnrollment
(
e
)
{
return
(
e
.
city_id
==
c
.
city_id
&&
e
.
year
==
c
.
year
&&
e
.
location_id
==
1
);
}
function
filterRuralEnrollment
(
e
)
{
return
(
e
.
city_id
==
c
.
city_id
&&
e
.
year
==
c
.
year
&&
e
.
location_id
==
2
);
}
let
urbanEnrollments
=
req
.
enrollment
.
filter
(
filterUrbanEnrollment
);
let
ruralEnrollments
=
req
.
enrollment
.
filter
(
filterRuralEnrollment
);
let
r
=
c
;
let
r
=
c
;
// r.locations[0].enrollments = urbanEnrollments;
// Para cada localização
// r.locations[1].enrollments = ruralEnrollments;
c
.
locations
.
forEach
((
location
,
index
)
=>
{
function
filterEnrollment
(
e
)
{
return
(
e
.
city_id
==
c
.
city_id
&&
e
.
year
==
c
.
year
&&
e
.
location_id
==
location
.
location_id
);
}
let
fEnrollments
=
req
.
enrollment
.
filter
(
filterEnrollment
);
let
educationLevels
=
[];
fEnrollments
.
forEach
((
fe
)
=>
{
let
obj
=
{
education_level_short_id
:
fe
.
education_level_short_id
,
education_level_short_name
:
fe
.
education_level_short_name
};
if
(
educationLevels
.
findIndex
((
el
)
=>
{
return
el
.
education_level_short_id
===
obj
.
education_level_short_id
})
===
-
1
)
{
educationLevels
.
push
(
obj
);
}
});
let
education_level
=
[];
// Para cada etapa de ensino
educationLevels
.
forEach
((
eduLevel
)
=>
{
function
filterEducationLevel
(
e
)
{
return
(
e
.
city_id
==
c
.
city_id
&&
e
.
year
==
c
.
year
&&
e
.
location_id
==
location
.
location_id
&&
e
.
education_level_short_id
==
eduLevel
.
education_level_short_id
);
}
let
fEducationLevel
=
fEnrollments
.
filter
(
filterEducationLevel
);
let
dayEnrollments
=
0
;
let
nightEnrollments
=
0
;
// Para cada matrícula na etapa de ensino
fEducationLevel
.
forEach
((
fEduLevel
)
=>
{
if
(
fEduLevel
.
period_id
<
3
)
dayEnrollments
+=
fEduLevel
.
total
;
else
if
(
fEduLevel
.
period_id
===
3
)
nightEnrollments
+=
fEduLevel
.
total
;
});
let
size
=
classSize
.
find
((
el
)
=>
{
return
el
.
id
===
eduLevel
.
education_level_short_id
;
});
let
fullPeriodTime
=
integralTime
.
find
((
el
)
=>
{
return
el
.
id
===
eduLevel
.
education_level_short_id
;
});
if
(
typeof
size
===
'
undefined
'
||
typeof
fullPeriodTime
===
'
undefined
'
)
return
;
size
=
size
.
numberStudentClass
;
fullPeriodTime
=
fullPeriodTime
.
offerGoal
;
let
fullPeriodClasses
=
Math
.
ceil
((
dayEnrollments
*
(
fullPeriodTime
/
100
))
/
size
);
let
dayClasses
=
Math
.
ceil
((
dayEnrollments
/
size
)
-
fullPeriodClasses
);
let
nightClasses
=
Math
.
ceil
(
nightEnrollments
/
size
);
let
totalClassroomsNeeded
=
fullPeriodClasses
+
dayClasses
;
if
(
nightClasses
>
dayClasses
)
totalClassroomsNeeded
+=
(
nightClasses
-
dayClasses
);
let
obj
=
{
total_enrollment_day
:
dayEnrollments
,
total_enrollment_night
:
nightEnrollments
,
full_period_classes
:
fullPeriodClasses
,
day_classes
:
dayClasses
,
night_classes
:
nightClasses
,
total_classrooms_needed
:
totalClassroomsNeeded
};
let
educationLevelIndex
=
education_level
.
findIndex
((
el
)
=>
{
return
el
.
education_level_short_id
===
eduLevel
.
education_level_short_id
});
if
(
educationLevelIndex
===
-
1
)
{
educationLevelIndex
=
education_level
.
length
;
education_level
.
push
(
eduLevel
);
}
education_level
[
educationLevelIndex
].
enrollment
=
obj
;
// education_level[educationLevelIndex].enrollments = fEducationLevel;
});
r
.
locations
[
index
].
education_level
=
education_level
;
});
result
.
push
(
r
);
result
.
push
(
r
);
});
});
console
.
log
(
'
FEITO
'
);
// console.log('FEITO');
// console.log('SALAS');
// console.log(classroom[0]);
// console.log('FILTRO');
// console.log(classEnrollments);
req
.
result
=
result
;
req
.
result
=
result
;
next
();
next
();
},
response
(
'
classroom_count
'
));
},
response
(
'
classroom_count
'
));
...
...
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