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
79dad9e5
Commit
79dad9e5
authored
7 years ago
by
Fernando Erd
Browse files
Options
Downloads
Patches
Plain Diff
Add match queries
parent
50e3c555
No related branches found
Branches containing commit
No related tags found
2 merge requests
!116
Release v1.0.0
,
!109
Enrollment liquid ratio
Changes
2
Hide 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/liquidEnrollmentRatio.js
+44
-10
44 additions, 10 deletions
src/libs/routes/liquidEnrollmentRatio.js
with
47 additions
and
10 deletions
src/libs/routes/api.js
+
3
−
0
View file @
79dad9e5
...
@@ -36,6 +36,8 @@ const rateSchool = require('./rateSchool')
...
@@ -36,6 +36,8 @@ const rateSchool = require('./rateSchool')
const
glossEnrollmentRatio
=
require
(
'
./glossEnrollmentRatio
'
)
const
glossEnrollmentRatio
=
require
(
'
./glossEnrollmentRatio
'
)
const
liquidEnrollmentRatio
=
require
(
'
./liquidEnrollmentRatio
'
)
const
idhm
=
require
(
'
./idhm
'
);
const
idhm
=
require
(
'
./idhm
'
);
const
idhmr
=
require
(
'
./idhmr
'
);
const
idhmr
=
require
(
'
./idhmr
'
);
...
@@ -80,6 +82,7 @@ api.use('/pibpercapita', pibpercapita);
...
@@ -80,6 +82,7 @@ api.use('/pibpercapita', pibpercapita);
api
.
use
(
'
/population
'
,
population
);
api
.
use
(
'
/population
'
,
population
);
api
.
use
(
'
/rate_school
'
,
rateSchool
);
api
.
use
(
'
/rate_school
'
,
rateSchool
);
api
.
use
(
'
/gloss_enrollment_ratio
'
,
glossEnrollmentRatio
);
api
.
use
(
'
/gloss_enrollment_ratio
'
,
glossEnrollmentRatio
);
api
.
use
(
'
/liquid_enrollment_ratio
'
,
liquidEnrollmentRatio
);
api
.
use
(
'
/idhml
'
,
idhml
);
api
.
use
(
'
/idhml
'
,
idhml
);
api
.
use
(
'
/auth/token
'
,
oauth2
.
token
);
api
.
use
(
'
/auth/token
'
,
oauth2
.
token
);
api
.
use
(
'
/verify
'
,
verifyToken
);
api
.
use
(
'
/verify
'
,
verifyToken
);
...
...
This diff is collapsed.
Click to expand it.
src/libs/routes/liquidEnrollmentRatio.js
+
44
−
10
View file @
79dad9e5
...
@@ -235,6 +235,46 @@ rqf.addField({
...
@@ -235,6 +235,46 @@ rqf.addField({
}
}
});
});
function
matchQueries
(
queryTotal
,
queryPartial
)
{
let
match
=
[];
queryTotal
.
forEach
((
result
)
=>
{
let
newObj
=
{};
let
keys
=
Object
.
keys
(
result
);
keys
.
forEach
((
key
)
=>
{
newObj
[
key
]
=
result
[
key
];
});
let
index
=
keys
.
indexOf
(
'
total
'
);
if
(
index
>
-
1
)
keys
.
splice
(
index
,
1
);
let
objMatch
=
null
;
for
(
let
i
=
0
;
i
<
queryPartial
.
length
;
++
i
)
{
let
partial
=
queryPartial
[
i
];
let
foundMatch
=
true
;
for
(
let
j
=
0
;
j
<
keys
.
length
;
++
j
)
{
let
key
=
keys
[
j
];
if
(
partial
[
key
]
!==
result
[
key
])
{
foundMatch
=
false
;
break
;
}
}
if
(
foundMatch
)
{
objMatch
=
partial
;
break
;
}
}
if
(
objMatch
)
{
newObj
.
total
=
(
objMatch
.
total
/
result
.
total
)
*
100
;
newObj
.
partial
=
objMatch
.
total
;
newObj
.
denominator
=
result
.
total
match
.
push
(
newObj
);
}
});
return
match
;
}
glossEnrollmentRatioApp
.
get
(
'
/
'
,
rqf
.
parse
(),(
req
,
res
,
next
)
=>
{
glossEnrollmentRatioApp
.
get
(
'
/
'
,
rqf
.
parse
(),(
req
,
res
,
next
)
=>
{
req
.
numerator
=
{};
req
.
numerator
=
{};
req
.
denominator
=
{};
req
.
denominator
=
{};
...
@@ -327,16 +367,10 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
...
@@ -327,16 +367,10 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
//division to generate req.result final
//division to generate req.result final
req
.
result
=
[]
req
.
result
=
[]
for
(
let
i
=
0
;
i
<
req
.
numerator
.
length
;
i
++
)
{
log
.
debug
(
Object
.
keys
(
req
.
dims
))
for
(
let
j
=
0
;
j
<
req
.
denominator
.
length
;
j
++
)
{
let
school_place
=
matchQueries
(
req
.
denominator
,
req
.
numerator
);
if
(
req
.
numerator
[
i
].
year
==
req
.
denominator
[
j
].
year
)
{
req
.
result
=
school_place
;
req
.
numerator
[
i
].
total
=
req
.
numerator
[
i
].
total
/
req
.
denominator
[
j
].
total
;
req
.
result
.
push
(
req
.
numerator
[
i
]);
}
}
}
next
();
next
();
},
response
(
'
gloss
EnrollmentRatio
'
));
},
response
(
'
liquuid
EnrollmentRatio
'
));
module
.
exports
=
glossEnrollmentRatioApp
;
module
.
exports
=
glossEnrollmentRatioApp
;
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