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
Merge requests
!412
Adds keys for non aggregate fields in the convert obj
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Adds keys for non aggregate fields in the convert obj
fix_non_aggregate_filters
into
development
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
lgtg20
requested to merge
fix_non_aggregate_filters
into
development
8 months ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
development
development (base)
and
latest version
latest version
c6553bc1
1 commit,
8 months ago
1 file
+
17
−
14
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/libs/middlewares/aggregateData.js
+
17
−
14
Options
@@ -2,21 +2,25 @@ const id2str = require(`./id2str`);
/*
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.
*/
// Faz o mapeamento dos filtros com seus respectivos
"
id2str
"
// Faz o mapeamento dos filtros com seus respectivos
'
id2str
'
const
convert
=
{
"
adm_dependency_detailed
"
:
"
admDependencyPriv
"
,
"
age_range
"
:
"
ageRangeAggregate
"
,
"
gender
"
:
"
gender
"
,
"
ethnic_group
"
:
"
ethnicGroup
"
,
"
education_level_mod_agg
"
:
"
educationLevelModAgg
"
,
'
integral_time_agg
'
:
'
integralTime
'
,
'
period_agg
'
:
'
period
'
,
'
modality_integral_time
'
:
'
educationLevelBasic
'
,
'
especial_education
'
:
'
especialEducation
'
adm_dependency_detailed
:
'
admDependencyPriv
'
,
location
:
'
location
'
,
diff_location
:
'
diffLocation
'
,
region
:
'
regionCode
'
,
state
:
'
stateName
'
,
age_range
:
'
ageRangeAggregate
'
,
gender
:
'
gender
'
,
ethnic_group
:
'
ethnicGroup
'
,
education_level_mod_agg
:
'
educationLevelModAgg
'
,
integral_time_agg
:
'
integralTime
'
,
period_agg
:
'
period
'
,
modality_integral_time
:
'
educationLevelBasic
'
,
especial_education
:
'
especialEducation
'
}
function
aggregateData
(
req
,
res
,
next
)
{
@@ -30,14 +34,13 @@ function aggregateData(req, res, next) {
// Verifica se o filtro passado está presente nos filtros agregados
fields
.
forEach
(
field
=>
{
if
(
aggregateFields
.
includes
(
field
))
currentAggregateField
=
field
;
else
currentNonAggregateField
=
field
});
console
.
log
(
convert
[
currentAggregateField
])
if
(
currentAggregateField
)
{
req
.
result
.
forEach
((
r
)
=>
{
// Alguns filtros começam com o id = 0 outros id = 1
id
=
[
'
ethnic_group
'
,
'
integral_time_agg
'
].
includes
(
currentAggregateField
)
?
0
:
1
;
for
(
const
property
in
r
)
{
// Dados agregados são identificados com a substring
"
total_
"
em sua chave
if
(
property
.
includes
(
"
total_
"
))
{
// Dados agregados são identificados com a substring
'
total_
'
em sua chave
if
(
property
.
includes
(
'
total_
'
))
{
let
data
=
{
total
:
r
[
property
],
year
:
r
.
year
,
Loading