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
ea9d7bc5
Commit
ea9d7bc5
authored
6 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Try to reutilize dims filed
parent
943702db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes/classroomCount.js
+24
-10
24 additions, 10 deletions
src/libs/routes/classroomCount.js
with
24 additions
and
10 deletions
src/libs/routes/classroomCount.js
+
24
−
10
View file @
ea9d7bc5
...
...
@@ -229,8 +229,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
next
();
},
rqf
.
build
(),
query
,
id2str
.
transform
(),
(
req
,
res
,
next
)
=>
{
delete
req
.
dims
;
delete
req
.
filter
;
next
();
},
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
console
.
log
(
'
dims
'
,
req
.
dims
);
req
.
classroom
=
req
.
result
;
let
classroom
=
[];
...
...
@@ -243,19 +246,30 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let
hashSet
=
new
Set
();
while
(
i
<
req
.
classroom
.
length
)
{
let
classroom
=
req
.
classroom
[
i
];
// Cria hash única para cada cidade, dado um ano
let
hash
=
''
+
classroom
.
year
+
classroom
.
city_id
;
// Cria hash única para cada espacialidade, dado um ano
let
hash
=
''
+
classroom
.
year
;
if
(
req
.
dims
.
state
)
hash
+=
''
+
classroom
.
state_id
;
if
(
req
.
dims
.
city
)
hash
+=
''
+
classroom
.
state_id
+
classroom
.
city_id
;
// Estrutura do objeto do resultado final
let
obj
=
{
year
:
classroom
.
year
,
name
:
classroom
.
name
,
state_id
:
classroom
.
state_id
,
state_name
:
classroom
.
state_name
,
city_id
:
classroom
.
city_id
,
city_name
:
classroom
.
city_name
,
locations
:
[]
};
if
(
req
.
dims
.
state
)
{
obj
.
state_id
=
classroom
.
state_id
;
obj
.
state_name
=
classroom
.
state_name
;
}
console
.
log
(
'
city
'
,
req
.
dims
.
city
);
if
(
req
.
dims
.
city
)
{
obj
.
state_id
=
classroom
.
state_id
;
obj
.
state_name
=
classroom
.
state_name
;
obj
.
city_id
=
classroom
.
city_id
;
obj
.
city_name
=
classroom
.
city_name
;
}
let
currentClassroomObj
=
null
;
if
(
!
hashSet
.
has
(
hash
)
)
{
hashSet
.
add
(
hash
);
...
...
@@ -388,9 +402,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
++
i
;
}
// TODO: agregar por estado e brasil
if
(
req
.
query
[
'
state
'
]
)
{
if
(
req
.
dims
.
state
)
{
console
.
log
(
'
ESTADO!!!!
'
);
}
else
if
(
!
req
.
query
[
'
city
'
]
)
{
}
else
if
(
!
req
.
dims
.
city
)
{
console
.
log
(
'
BRASIL!!!
'
);
}
...
...
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