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
ca4dc04f
There was a problem fetching the pipeline summary.
Commit
ca4dc04f
authored
7 years ago
by
Glenda Train
Browse files
Options
Downloads
Patches
Plain Diff
Add auxiliar indicator
parent
e1882e94
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!136
Auxiliar indicator
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/routes/api.js
+3
-0
3 additions, 0 deletions
src/libs/routes/api.js
src/libs/routes/auxiliar.js
+334
-0
334 additions, 0 deletions
src/libs/routes/auxiliar.js
with
337 additions
and
0 deletions
src/libs/routes/api.js
+
3
−
0
View file @
ca4dc04f
...
@@ -66,6 +66,8 @@ const classroomCount = require(`${libs}/routes/classroomCount`);
...
@@ -66,6 +66,8 @@ const classroomCount = require(`${libs}/routes/classroomCount`);
const
transport
=
require
(
`./transport`
);
const
transport
=
require
(
`./transport`
);
const
auxiliar
=
require
(
`
${
libs
}
/routes/auxiliar`
);
const
dailyChargeAmount
=
require
(
`
${
libs
}
/routes/dailyChargeAmount`
);
const
dailyChargeAmount
=
require
(
`
${
libs
}
/routes/dailyChargeAmount`
);
api
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
api
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
...
@@ -104,5 +106,6 @@ api.use('/out_of_school', outOfSchool);
...
@@ -104,5 +106,6 @@ api.use('/out_of_school', outOfSchool);
api
.
use
(
'
/classroom_count
'
,
classroomCount
);
api
.
use
(
'
/classroom_count
'
,
classroomCount
);
api
.
use
(
'
/daily_charge_amount
'
,
dailyChargeAmount
);
api
.
use
(
'
/daily_charge_amount
'
,
dailyChargeAmount
);
api
.
use
(
'
/transport
'
,
transport
);
api
.
use
(
'
/transport
'
,
transport
);
api
.
use
(
'
/auxiliar
'
,
auxiliar
);
module
.
exports
=
api
;
module
.
exports
=
api
;
This diff is collapsed.
Click to expand it.
src/libs/routes/auxiliar.js
0 → 100644
+
334
−
0
View file @
ca4dc04f
const
express
=
require
(
'
express
'
);
const
auxiliarApp
=
express
.
Router
();
const
libs
=
`
${
process
.
cwd
()}
/libs`
;
const
log
=
require
(
`
${
libs
}
/log`
)(
module
);
const
squel
=
require
(
'
squel
'
);
const
query
=
require
(
`
${
libs
}
/middlewares/query`
).
query
;
const
response
=
require
(
`
${
libs
}
/middlewares/response`
);
const
ReqQueryFields
=
require
(
`
${
libs
}
/middlewares/reqQueryFields`
);
const
id2str
=
require
(
`
${
libs
}
/middlewares/id2str`
);
const
config
=
require
(
`
${
libs
}
/config`
);
const
passport
=
require
(
'
passport
'
);
const
download
=
require
(
`
${
libs
}
/middlewares/downloadDatabase`
);
const
addMissing
=
require
(
`
${
libs
}
/middlewares/addMissing`
);
const
cache
=
require
(
'
apicache
'
).
options
({
debug
:
config
.
debug
,
statusCodes
:
{
include
:
[
200
]}
}).
middleware
;
let
rqf
=
new
ReqQueryFields
();
auxiliarApp
.
use
(
cache
(
'
15 day
'
));
auxiliarApp
.
get
(
'
/year_range
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
docente
'
)
.
field
(
'
MIN(docente.ano_censo)
'
,
'
start_year
'
)
.
field
(
'
MAX(docente.ano_censo)
'
,
'
end_year
'
);
next
();
},
query
,
response
(
'
range
'
));
auxiliarApp
.
get
(
'
/years
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
docente
'
).
field
(
'
DISTINCT docente.ano_censo
'
,
'
year
'
);
next
();
},
query
,
response
(
'
years
'
));
auxiliarApp
.
get
(
'
/source
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
fonte
'
)
.
field
(
'
fonte
'
,
'
source
'
)
.
where
(
'
tabela =
\'
docente
\'
'
);
next
();
},
query
,
response
(
'
source
'
))
// Dependência administrativa
auxiliarApp
.
get
(
'
/adm_dependency_detailed
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
1
;
i
<=
6
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
admDependencyPriv
(
i
)
});
};
next
();
},
response
(
'
adm_dependency_detailed
'
));
// Dependência administrativa com detalhamento das escolas privadas
auxiliarApp
.
get
(
'
/adm_dependency
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
1
;
i
<=
4
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
admDependency
(
i
)
});
};
next
();
},
response
(
'
adm_dependency
'
));
// Área da localidade
auxiliarApp
.
get
(
'
/location
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
1
;
i
<=
2
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
location
(
i
)
});
};
next
();
},
response
(
'
location
'
));
// Área da localidade por tipo de área rural
auxiliarApp
.
get
(
'
/rural_location
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[
{
id
:
1
,
name
:
"
Urbana
"
},
{
id
:
2
,
name
:
"
Rural
"
},
{
id
:
3
,
name
:
"
Rural - Área de assentamento
"
},
{
id
:
4
,
name
:
"
Rural - Terra indígena
"
},
{
id
:
5
,
name
:
"
Rural - Área remanescente de quilombos
"
},
{
id
:
6
,
name
:
"
Rural - Unidade de uso sustentável
"
}
];
next
();
},
response
(
'
rural_location
'
));
// Etapa e modalidade por segmento
auxiliarApp
.
get
(
'
/education_level_mod
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
1
;
i
<=
11
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
educationLevelMod
(
i
)
});
}
req
.
result
.
push
({
id
:
99
,
name
:
id2str
.
educationLevelMod
(
99
)
});
next
();
},
response
(
'
education_level_mod
'
));
// Sexo
auxiliarApp
.
get
(
'
/gender
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[
{
id
:
1
,
name
:
'
Masculino
'
},
{
id
:
2
,
name
:
'
Feminino
'
}
];
next
();
},
response
(
'
gender
'
));
// Raça/Cor
auxiliarApp
.
get
(
'
/ethnic_group
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[];
for
(
let
i
=
0
;
i
<=
5
;
++
i
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
ethnicGroup
(
i
)
});
}
next
();
},
response
(
'
ethnic_group
'
));
// Filtros
rqf
.
addField
({
name
:
'
filter
'
,
field
:
false
,
where
:
true
}).
addField
({
name
:
'
dims
'
,
field
:
true
,
where
:
false
// Dependência administrativa [CEBES013N0]
}).
addValue
({
name
:
'
adm_dependency
'
,
table
:
'
docente
'
,
tableField
:
'
dependencia_adm_id
'
,
resultField
:
'
adm_dependency_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
dependencia_adm_id
'
}
// Dependência administrativa com detalhamento das escolas privadas [CEBES013T1]
}).
addValue
({
name
:
'
adm_dependency_detailed
'
,
table
:
'
docente
'
,
tableField
:
'
dependencia_adm_priv
'
,
resultField
:
'
adm_dependency_detailed_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
dependencia_adm_priv
'
}
// Etapa e modalidade por segmento [CEBDO009N0T1]
}).
addValue
({
name
:
'
education_level_mod
'
,
table
:
'
docente
'
,
tableField
:
'
etapas_mod_ensino_segmento_id
'
,
resultField
:
'
education_level_mod_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
etapas_mod_ensino_segmento_id
'
}
}).
addValue
({
name
:
'
region
'
,
table
:
'
regiao
'
,
tableField
:
'
nome
'
,
resultField
:
'
region_name
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
id
'
},
join
:
{
primary
:
'
id
'
,
foreign
:
'
escola_regiao_id
'
,
foreignTable
:
'
docente
'
}
}).
addValue
({
name
:
'
state
'
,
table
:
'
estado
'
,
tableField
:
'
nome
'
,
resultField
:
'
state_name
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
id
'
},
join
:
{
primary
:
'
id
'
,
foreign
:
'
escola_estado_id
'
,
foreignTable
:
'
docente
'
}
}).
addValueToField
({
name
:
'
city
'
,
table
:
'
municipio
'
,
tableField
:
[
'
nome
'
,
'
id
'
],
resultField
:
[
'
city_name
'
,
'
city_id
'
],
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
id
'
},
join
:
{
primary
:
'
id
'
,
foreign
:
'
escola_municipio_id
'
,
foreignTable
:
'
docente
'
}
},
'
dims
'
).
addValueToField
({
name
:
'
city
'
,
table
:
'
municipio
'
,
tableField
:
'
nome
'
,
resultField
:
'
city_name
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
id
'
},
join
:
{
primary
:
'
id
'
,
foreign
:
'
escola_municipio_id
'
,
foreignTable
:
'
docente
'
}
// Área da localidade [CEBES014N0]
},
'
filter
'
).
addValue
({
name
:
'
location
'
,
table
:
'
docente
'
,
tableField
:
'
cod_localizacao
'
,
resultField
:
'
location_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
cod_localizacao
'
}
// Área da localidade por tipo de área rural [CEBES014T1]
}).
addValue
({
name
:
'
rural_location
'
,
table
:
'
docente
'
,
tableField
:
'
localidade_area_rural
'
,
resultField
:
'
rural_location_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
localidade_area_rural
'
}
}).
addValue
({
name
:
'
min_year
'
,
table
:
'
docente
'
,
tableField
:
'
ano_censo
'
,
resultField
:
'
year
'
,
where
:
{
relation
:
'
>=
'
,
type
:
'
integer
'
,
field
:
'
ano_censo
'
}
}).
addValue
({
name
:
'
max_year
'
,
table
:
'
docente
'
,
tableField
:
'
ano_censo
'
,
resultField
:
'
year
'
,
where
:
{
relation
:
'
<=
'
,
type
:
'
integer
'
,
field
:
'
ano_censo
'
}
// Sexo [CEBDO008N0]
}).
addValue
({
name
:
'
gender
'
,
table
:
'
docente
'
,
tableField
:
'
sexo
'
,
resultField
:
'
gender_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
sexo
'
}
// Cor/Raça [CEBDO009N0]
}).
addValue
({
name
:
'
ethnic_group
'
,
table
:
'
docente
'
,
tableField
:
'
cor_raca
'
,
resultField
:
'
ethnic_group_id
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
cor_raca
'
}
});
// Lab dados
auxiliarApp
.
get
(
'
/
'
,
rqf
.
parse
(),
(
req
,
res
,
next
)
=>
{
req
.
sql
.
field
(
'
COUNT(DISTINCT docente.id)
'
,
'
total
'
)
.
field
(
"
'Brasil'
"
,
'
name
'
)
.
field
(
'
docente.ano_censo
'
,
'
year
'
)
.
from
(
'
docente
'
)
.
group
(
'
docente.ano_censo
'
)
.
order
(
'
docente.ano_censo
'
)
.
where
(
'
((docente.tipo_turma_id <= 3) AND (docente.dependencia_adm_id = 2 OR docente.dependencia_adm_id = 3) AND (docente.tipo_docente = 2))
'
);
next
();
},
rqf
.
build
(),
query
,
addMissing
(
rqf
),
id2str
.
transform
(),
response
(
'
auxiliar
'
));
// SimCAQ
auxiliarApp
.
get
(
'
/count
'
,
rqf
.
parse
(),
(
req
,
res
,
next
)
=>
{
req
.
sql
.
field
(
'
COUNT(DISTINCT docente.id)
'
,
'
total
'
)
.
field
(
"
'Brasil'
"
,
'
name
'
)
.
field
(
'
docente.ano_censo
'
,
'
year
'
)
.
from
(
'
docente
'
)
.
group
(
'
docente.ano_censo
'
)
.
order
(
'
docente.ano_censo
'
)
.
where
(
'
(docente.tipo_turma_id <= 3 AND docente.tipo_docente = 2)
'
);
next
();
},
rqf
.
build
(),
query
,
addMissing
(
rqf
),
id2str
.
transform
(),
response
(
'
auxiliar
'
));
auxiliarApp
.
get
(
'
/download
'
,
passport
.
authenticate
(
'
bearer
'
,
{
session
:
false
}),
rqf
.
parse
(),
rqf
.
build
(),
download
(
'
docente
'
,
'
mapping_docente
'
));
module
.
exports
=
auxiliarApp
;
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