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
b02ca7e7
There was a problem fetching the pipeline summary.
Commit
b02ca7e7
authored
7 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add tests to RQF
parent
e946a55c
No related branches found
No related tags found
1 merge request
!116
Release v1.0.0
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/middlewares/reqQueryFields.js
+20
-11
20 additions, 11 deletions
src/libs/middlewares/reqQueryFields.js
src/test/enrollment.js
+14
-0
14 additions, 0 deletions
src/test/enrollment.js
with
34 additions
and
11 deletions
src/libs/middlewares/reqQueryFields.js
+
20
−
11
View file @
b02ca7e7
...
@@ -9,13 +9,18 @@ function parseWhereValue(type, value) {
...
@@ -9,13 +9,18 @@ function parseWhereValue(type, value) {
if
(
type
===
'
double
'
)
return
parseFloat
(
value
);
if
(
type
===
'
double
'
)
return
parseFloat
(
value
);
if
(
type
===
'
string
'
)
return
'
%
'
+
value
+
'
%
'
;
if
(
type
===
'
string
'
)
return
'
%
'
+
value
+
'
%
'
;
if
(
type
===
'
boolean
'
)
{
if
(
type
===
'
boolean
'
)
{
if
(
value
.
toLowerCase
()
===
'
null
'
)
{
if
(
value
===
null
||
typeof
value
===
'
boolean
'
)
{
console
.
log
(
'
Fazendo uma consulta Null
'
);
return
value
;
return
null
;
}
else
{
console
.
log
(
'
Fazendo uma consulta True
'
);
return
(
value
.
toLowerCase
()
===
'
true
'
||
parseInt
(
value
,
10
)
===
1
);
}
}
if
(
typeof
value
===
'
string
'
)
{
if
(
value
.
toLowerCase
()
===
'
true
'
||
value
.
toLowerCase
()
===
'
1
'
)
{
return
true
;
}
if
(
value
.
toLowerCase
()
===
'
null
'
)
{
return
null
;
}
}
return
false
;
}
}
}
}
...
@@ -152,7 +157,15 @@ class ReqQueryFields {
...
@@ -152,7 +157,15 @@ class ReqQueryFields {
// Fazemos o split e temos um array `['state', 41]`
// Fazemos o split e temos um array `['state', 41]`
const
kv
=
param
.
split
(
'
:
'
);
const
kv
=
param
.
split
(
'
:
'
);
// Checa se há um valor. Se não tem, definimos como true.
// Checa se há um valor. Se não tem, definimos como true.
obj
[
kv
[
0
]]
=
(
typeof
kv
[
1
]
===
'
undefined
'
)
?
true
:
JSON
.
parse
(
kv
[
1
]);
if
(
(
typeof
kv
[
1
]
===
'
undefined
'
))
{
obj
[
kv
[
0
]]
=
true
;
}
else
{
try
{
obj
[
kv
[
0
]]
=
JSON
.
parse
(
kv
[
1
]);
}
catch
(
err
)
{
obj
[
kv
[
0
]]
=
kv
[
1
];
}
}
// `obj` é agora `{kv[0]: kv[1]}` ou `{kv[0]: true}`.
// `obj` é agora `{kv[0]: kv[1]}` ou `{kv[0]: true}`.
// No exemplo `{'state': 41}`
// No exemplo `{'state': 41}`
}
}
...
@@ -243,10 +256,6 @@ class ReqQueryFields {
...
@@ -243,10 +256,6 @@ class ReqQueryFields {
log
.
debug
(
'
whereValue
'
);
log
.
debug
(
'
whereValue
'
);
log
.
debug
(
whereValue
);
log
.
debug
(
whereValue
);
log
.
debug
(
`Where value é array?
${
Array
.
isArray
(
whereValue
)}
`
);
log
.
debug
(
`Where value é array?
${
Array
.
isArray
(
whereValue
)}
`
);
// TODO: |
// TODO: |
// TODO: V
//TODO: parse do valor do where onde apropriado!!!!!!!
let
tbl
=
value
.
where
.
table
||
value
.
table
;
let
tbl
=
value
.
where
.
table
||
value
.
table
;
// multiple where, only tested for boolean filds
// multiple where, only tested for boolean filds
...
...
This diff is collapsed.
Click to expand it.
src/test/enrollment.js
+
14
−
0
View file @
b02ca7e7
...
@@ -237,6 +237,20 @@ describe('request enrollments', () => {
...
@@ -237,6 +237,20 @@ describe('request enrollments', () => {
});
});
});
});
it
(
'
should list enrollments with multivalue filter and single value filter
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/enrollment?filter=region:[1,2],min_year:2015
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
result
'
);
res
.
body
.
result
.
should
.
be
.
a
(
'
array
'
);
res
.
body
.
result
[
0
].
should
.
have
.
property
(
'
name
'
);
res
.
body
.
result
[
0
].
should
.
have
.
property
(
'
total
'
);
done
();
});
});
it
(
'
should list enrollments with valid dimensions and filters
'
,
(
done
)
=>
{
it
(
'
should list enrollments with valid dimensions and filters
'
,
(
done
)
=>
{
chai
.
request
(
server
)
chai
.
request
(
server
)
.
get
(
'
/api/v1/enrollment?dims=region,state,school_year,school,gender,period&filter=min_year:2015,max_year:2015,city:4106902
'
)
.
get
(
'
/api/v1/enrollment?dims=region,state,school_year,school,gender,period&filter=min_year:2015,max_year:2015,city:4106902
'
)
...
...
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