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
608e758e
Commit
608e758e
authored
6 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature_classes_school_year' into release_v1.8.0
Related: simcaq/SCRUM#408
parents
eca78673
ed940644
No related branches found
No related tags found
1 merge request
!162
V1.8.0
Pipeline
#18428
failed
6 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-1
1 addition, 1 deletion
CHANGELOG.md
src/libs/routes/classroomCount.js
+112
-11
112 additions, 11 deletions
src/libs/routes/classroomCount.js
with
113 additions
and
12 deletions
CHANGELOG.md
+
1
−
1
View file @
608e758e
...
...
@@ -8,10 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
-
Add financial route
-
Add employees route
### Changed
-
Fix transport route
-
Fix return where integral time is null
-
Classroom count route returns school year results for education level 1
## 1.7.0 - 2018-09-20
### Changed
...
...
This diff is collapsed.
Click to expand it.
src/libs/routes/classroomCount.js
+
112
−
11
View file @
608e758e
...
...
@@ -163,8 +163,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let
classSize
=
JSON
.
parse
(
req
.
body
.
class_size
)
||
null
;
let
integralTime
=
JSON
.
parse
(
req
.
body
.
integral_time
)
||
null
;
console
.
log
(
classSize
,
integralTime
);
if
(
classSize
==
null
||
integralTime
==
null
)
{
res
.
statusCode
=
400
;
return
res
.
json
({
err
:
{
message
:
"
There was an error processing class_size or integral_time. Check your JSON sintax and be sure you're sending both paramenters.
"
}});
...
...
@@ -197,7 +195,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
if
(
id2str
.
schoolYear
(
i
)
!==
id2str
.
schoolYear
(
99
))
{
let
educationLevelId
=
Math
.
floor
(
i
/
10
);
let
classSize
=
req
.
classSize
.
find
((
el
)
=>
{
return
el
.
id
===
educationLevelId
});
let
classSize
=
req
.
classSize
.
find
((
el
)
=>
{
return
el
.
id
===
educationLevelId
||
el
.
id
===
i
});
let
integralTime
=
req
.
integralTime
.
find
((
el
)
=>
{
return
el
.
id
===
educationLevelId
});
let
numberStudentClass
=
(
typeof
classSize
!==
'
undefined
'
)
?
classSize
.
numberStudentClass
:
null
;
...
...
@@ -286,6 +284,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let
enrollmentMatch
=
true
;
j
=
0
;
let
educationLevelSet
=
new
Set
();
let
schoolYearSet
=
new
Set
();
let
enrollment
=
enrollments
[
j
];
while
(
enrollmentMatch
&&
j
<
enrollments
.
length
)
{
...
...
@@ -347,6 +346,10 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
}
};
if
(
enrollmentEducationLevel
.
id
==
1
)
{
educationLevel
.
classes_school_year
=
[];
}
// Para manter a ordem da etapa de ensino
if
(
location
.
education_level
.
length
==
0
)
{
location
.
education_level
.
push
(
educationLevel
);
...
...
@@ -375,20 +378,54 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
educationLevel
=
location
.
education_level
[
k
];
}
// Adiciona as séries da creche
let
currentSchoolYear
=
null
;
if
(
enrollmentEducationLevel
.
id
==
1
){
let
schoolYearHash
=
''
+
enrollment
.
year
+
enrollment
.
city_id
+
enrollment
.
location_id
+
enrollment
.
school_year_id
;
if
(
schoolYearSet
.
has
(
schoolYearHash
))
{
// Busca a série escolar
let
k
=
0
;
let
el
=
educationLevel
.
classes_school_year
[
k
];
while
(
k
<
educationLevel
.
classes_school_year
.
length
)
{
if
(
el
.
school_year_id
!=
enrollment
.
school_year_id
)
{
++
k
;
if
(
k
<
educationLevel
.
classes_school_year
.
length
)
el
=
educationLevel
.
classes_school_year
[
k
];
}
else
break
;
}
if
(
k
>=
educationLevel
.
classes_school_year
.
length
)
--
k
;
currentSchoolYear
=
educationLevel
.
classes_school_year
[
k
];
}
else
{
// Adiciona uma nova série escolar
let
school_year
=
{
school_year_id
:
enrollment
.
school_year_id
,
school_year_name
:
enrollment
.
school_year_name
,
total_enrollment_day
:
0
,
total_enrollment_night
:
0
,
full_period_classes
:
0
,
day_classes
:
0
,
night_classes
:
0
,
total_classrooms_needed
:
0
}
schoolYearSet
.
add
(
schoolYearHash
);
educationLevel
.
classes_school_year
.
push
(
school_year
);
currentSchoolYear
=
school_year
;
}
}
let
currentOfferGoal
=
enrollmentEducationLevel
.
offerGoal
;
let
currentNumberStudentClass
=
(
enrollment
.
location_id
==
1
)
?
enrollmentEducationLevel
.
numberStudentClass
.
urban
:
enrollmentEducationLevel
.
numberStudentClass
.
country
;
// Soma os totais de matrícula da etapa de ensino
educationLevel
.
enrollment
.
total_enrollment_day
+=
(
enrollment
.
period_id
<
3
&&
enrollment
.
period_id
!=
null
)
?
enrollment
.
total
:
0
;
educationLevel
.
enrollment
.
total_enrollment_night
+=
(
enrollment
.
period_id
==
3
)
?
enrollment
.
total
:
0
;
// Calcula o número de turmas parcial
// Turmas de período integral
educationLevel
.
enrollment
.
full_period_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_day
*
(
enrollmentEducationLevel
.
offerGoal
/
100
))
/
enrollmentEducationLevel
.
n
umberStudentClass
);
educationLevel
.
enrollment
.
full_period_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_day
*
(
currentOfferGoal
/
100
))
/
currentN
umberStudentClass
);
// Turmas diurnas
// Matrículas diurnas - matrículas integrais
educationLevel
.
enrollment
.
day_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_day
*
(
1
-
enrollmentEducationLevel
.
offerGoal
/
100
))
/
enrollmentEducationLevel
.
numberStudentClass
);
// Turmas diurnas (matrículas diurnas - matrículas integrais)
educationLevel
.
enrollment
.
day_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_day
*
(
1
-
currentOfferGoal
/
100
))
/
currentNumberStudentClass
);
// Turmas noturnas
educationLevel
.
enrollment
.
night_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_night
/
enrollmentEducationLevel
.
n
umberStudentClass
));
educationLevel
.
enrollment
.
night_classes
=
Math
.
ceil
((
educationLevel
.
enrollment
.
total_enrollment_night
/
currentN
umberStudentClass
))
||
0
;
// Total de salas
educationLevel
.
enrollment
.
total_classrooms_needed
=
(
educationLevel
.
enrollment
.
full_period_classes
+
educationLevel
.
enrollment
.
day_classes
/
2
);
...
...
@@ -397,6 +434,33 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
educationLevel
.
enrollment
.
total_classrooms_needed
=
Math
.
ceil
(
educationLevel
.
enrollment
.
total_classrooms_needed
);
// Faz os mesmos cálculos para a série escolar
if
(
currentSchoolYear
)
{
// Totais de matrícula
currentSchoolYear
.
total_enrollment_day
+=
(
enrollment
.
period_id
<
3
&&
enrollment
.
period_id
!=
null
)
?
enrollment
.
total
:
0
;
currentSchoolYear
.
total_enrollment_night
+=
(
enrollment
.
period_id
==
3
)
?
enrollment
.
total
:
0
;
// Número de turmas parcial
currentSchoolYear
.
full_period_classes
=
Math
.
ceil
((
currentSchoolYear
.
total_enrollment_day
*
(
currentOfferGoal
/
100
))
/
currentNumberStudentClass
);
currentSchoolYear
.
day_classes
=
Math
.
ceil
((
currentSchoolYear
.
total_enrollment_day
*
(
1
-
currentOfferGoal
/
100
))
/
currentNumberStudentClass
);
currentSchoolYear
.
night_classes
=
Math
.
ceil
((
currentSchoolYear
.
total_enrollment_night
/
enrollmentEducationLevel
.
numberStudentClass
))
||
0
;
// Total de salas
currentSchoolYear
.
total_classrooms_needed
=
(
currentSchoolYear
.
full_period_classes
+
currentSchoolYear
.
day_classes
/
2
);
if
(
currentSchoolYear
.
night_classes
>
(
currentSchoolYear
.
day_classes
/
2
))
currentSchoolYear
.
total_classrooms_needed
+=
(
currentSchoolYear
.
night_classes
-
(
currentSchoolYear
.
day_classes
/
2
));
currentSchoolYear
.
total_classrooms_needed
=
Math
.
ceil
(
currentSchoolYear
.
total_classrooms_needed
);
function
reducer
(
key
)
{
return
(
sum
,
elem
)
=>
sum
+
elem
[
key
]}
educationLevel
.
enrollment
.
full_period_classes
=
educationLevel
.
classes_school_year
.
reduce
(
reducer
(
'
full_period_classes
'
),
0
);
educationLevel
.
enrollment
.
day_classes
=
educationLevel
.
classes_school_year
.
reduce
(
reducer
(
'
day_classes
'
),
0
);
educationLevel
.
enrollment
.
night_classes
=
educationLevel
.
classes_school_year
.
reduce
(
reducer
(
'
night_classes
'
),
0
);
educationLevel
.
enrollment
.
total_classrooms_needed
=
educationLevel
.
classes_school_year
.
reduce
(
reducer
(
'
total_classrooms_needed
'
),
0
);
}
enrollment
=
enrollments
[
j
];
}
...
...
@@ -470,10 +534,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
continue
;
}
// Fazer "merge" do array education_level
// Faz "merge" do array education_level
// Se a localidade atual não tem o vetor
if
(
currentLocation
.
education_level
.
length
==
0
)
{
currentLocation
.
education_level
=
[...
cityLocation
.
education_level
];
}
else
{
}
else
{
// Caso já tenha, atualiza os valores
let
l
=
0
;
while
(
l
<
cityLocation
.
education_level
.
length
)
{
let
cityEducation
=
cityLocation
.
education_level
[
l
];
...
...
@@ -493,6 +558,42 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
currentEducation
.
enrollment
.
day_classes
+=
cityEducation
.
enrollment
.
day_classes
;
currentEducation
.
enrollment
.
night_classes
+=
cityEducation
.
enrollment
.
night_classes
;
currentEducation
.
enrollment
.
total_classrooms_needed
+=
cityEducation
.
enrollment
.
total_classrooms_needed
;
if
((
typeof
cityEducation
.
classes_school_year
!==
'
undefined
'
)
&&
(
typeof
currentEducation
.
classes_school_year
!==
'
undefined
'
))
{
let
n
=
0
;
let
o
=
0
;
let
cityClass
=
null
;
let
currentClass
=
null
;
while
((
typeof
cityClass
!==
'
undefined
'
)
&&
(
typeof
currentClass
!==
'
undefined
'
))
{
cityClass
=
cityEducation
.
classes_school_year
[
o
];
currentClass
=
currentEducation
.
classes_school_year
[
n
];
// Se a série escolar é menor que a atual, ela não está no vetor, pois o vetor está ordenado e tem range limitado
if
(
cityClass
.
school_year_id
<
currentClass
.
school_year_id
)
{
currentEducation
.
classes_school_year
.
splice
(
n
,
0
,
cityClass
);
cityClass
=
cityEducation
.
classes_school_year
[
++
o
];
continue
;
}
else
if
(
cityClass
.
school_year_id
>
currentClass
.
school_year_id
)
{
currentClass
=
currentEducation
.
classes_school_year
[
++
n
];
// Se o ano escolar da cidade é maior que a localidade do objeto atual E o vetor de ano escolar do objeto atual
// acaba, então este ano escolar falta no objeto atual, pois os anos escolares estão ordenados
if
(
typeof
currentClass
==
'
undefined
'
&&
typeof
cityClass
!==
'
undefined
'
)
{
currentEducation
.
classes_school_year
[
n
]
=
cityClass
;
currentClass
=
currentEducation
.
classes_school_year
[
n
];
}
continue
;
}
currentClass
.
total_enrollment_day
+=
cityClass
.
total_enrollment_day
;
currentClass
.
total_enrollment_night
+=
cityClass
.
total_enrollment_night
;
currentClass
.
full_period_classes
+=
cityClass
.
full_period_classes
;
currentClass
.
day_classes
+=
cityClass
.
day_classes
;
currentClass
.
night_classes
+=
cityClass
.
night_classes
;
currentClass
.
total_classrooms_needed
+=
cityClass
.
total_classrooms_needed
;
cityClass
=
cityEducation
.
classes_school_year
[
++
o
];
}
}
}
else
{
if
(
currentEducation
.
education_level_short_id
<
cityEducation
.
education_level_short_id
)
{
currentLocation
.
education_level
.
splice
(
++
m
,
0
,
cityEducation
);
...
...
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