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
c6553bc1
Commit
c6553bc1
authored
11 months ago
by
lgtg20
Browse files
Options
Downloads
Patches
Plain Diff
Adds keys for non aggregate fields in the convert obj
parent
f646d1b6
No related branches found
No related tags found
3 merge requests
!417
[ADD] Indicator "Taxa de Atendimento Educacional" updated on production!
,
!416
[ADD] Route almost ready, some tests needed. Comments added and filters that...
,
!412
Adds keys for non aggregate fields in the convert obj
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/middlewares/aggregateData.js
+17
-14
17 additions, 14 deletions
src/libs/middlewares/aggregateData.js
with
17 additions
and
14 deletions
src/libs/middlewares/aggregateData.js
+
17
−
14
View file @
c6553bc1
...
@@ -2,21 +2,25 @@ const id2str = require(`./id2str`);
...
@@ -2,21 +2,25 @@ const id2str = require(`./id2str`);
/*
/*
Middleware que tem como função formatar dados agregados.
Middleware que tem como função formatar dados agregados.
Dados agregados não podem ser
"
puxados
"
do banco de dados da mesma maneira que os dados tradicioanis, dessa maneira é
Dados agregados não podem ser
'
puxados
'
do banco de dados da mesma maneira que os dados tradicioanis, dessa maneira é
necessário formatá-los para que sigam o padrão.
necessário formatá-los para que sigam o padrão.
*/
*/
// Faz o mapeamento dos filtros com seus respectivos
"
id2str
"
// Faz o mapeamento dos filtros com seus respectivos
'
id2str
'
const
convert
=
{
const
convert
=
{
"
adm_dependency_detailed
"
:
"
admDependencyPriv
"
,
adm_dependency_detailed
:
'
admDependencyPriv
'
,
"
age_range
"
:
"
ageRangeAggregate
"
,
location
:
'
location
'
,
"
gender
"
:
"
gender
"
,
diff_location
:
'
diffLocation
'
,
"
ethnic_group
"
:
"
ethnicGroup
"
,
region
:
'
regionCode
'
,
"
education_level_mod_agg
"
:
"
educationLevelModAgg
"
,
state
:
'
stateName
'
,
'
integral_time_agg
'
:
'
integralTime
'
,
age_range
:
'
ageRangeAggregate
'
,
'
period_agg
'
:
'
period
'
,
gender
:
'
gender
'
,
'
modality_integral_time
'
:
'
educationLevelBasic
'
,
ethnic_group
:
'
ethnicGroup
'
,
'
especial_education
'
:
'
especialEducation
'
education_level_mod_agg
:
'
educationLevelModAgg
'
,
integral_time_agg
:
'
integralTime
'
,
period_agg
:
'
period
'
,
modality_integral_time
:
'
educationLevelBasic
'
,
especial_education
:
'
especialEducation
'
}
}
function
aggregateData
(
req
,
res
,
next
)
{
function
aggregateData
(
req
,
res
,
next
)
{
...
@@ -30,14 +34,13 @@ function aggregateData(req, res, next) {
...
@@ -30,14 +34,13 @@ function aggregateData(req, res, next) {
// Verifica se o filtro passado está presente nos filtros agregados
// Verifica se o filtro passado está presente nos filtros agregados
fields
.
forEach
(
field
=>
{
if
(
aggregateFields
.
includes
(
field
))
currentAggregateField
=
field
;
else
currentNonAggregateField
=
field
});
fields
.
forEach
(
field
=>
{
if
(
aggregateFields
.
includes
(
field
))
currentAggregateField
=
field
;
else
currentNonAggregateField
=
field
});
console
.
log
(
convert
[
currentAggregateField
])
if
(
currentAggregateField
)
{
if
(
currentAggregateField
)
{
req
.
result
.
forEach
((
r
)
=>
{
req
.
result
.
forEach
((
r
)
=>
{
// Alguns filtros começam com o id = 0 outros id = 1
// Alguns filtros começam com o id = 0 outros id = 1
id
=
[
'
ethnic_group
'
,
'
integral_time_agg
'
].
includes
(
currentAggregateField
)
?
0
:
1
;
id
=
[
'
ethnic_group
'
,
'
integral_time_agg
'
].
includes
(
currentAggregateField
)
?
0
:
1
;
for
(
const
property
in
r
)
{
for
(
const
property
in
r
)
{
// Dados agregados são identificados com a substring
"
total_
"
em sua chave
// Dados agregados são identificados com a substring
'
total_
'
em sua chave
if
(
property
.
includes
(
"
total_
"
))
{
if
(
property
.
includes
(
'
total_
'
))
{
let
data
=
{
let
data
=
{
total
:
r
[
property
],
total
:
r
[
property
],
year
:
r
.
year
,
year
:
r
.
year
,
...
...
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