Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
9e6c8f95
Commit
9e6c8f95
authored
Dec 12, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix support for multiple query (more intuitive behaviour when refine fields are sent empty)
parent
a9a43415
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
extractDataCustom.py
comex_install/extractDataCustom.py
+29
-21
No files found.
comex_install/extractDataCustom.py
View file @
9e6c8f95
...
...
@@ -118,10 +118,13 @@ class MyExtractor:
elif
qtype
==
"filter"
:
sql_query
=
None
filter_dict
=
restparse
(
queryargs
)
# debug
print
(
"filter: REST query is"
,
queryargs
)
# print("filter: REST query is", filter_dict
)
if
"query"
in
queryargs
and
queryargs
[
"query"
]
==
"*"
:
if
"query"
in
filter_dict
and
filter_dict
[
"query"
]
==
"*"
:
print
(
"bombaclass"
)
# query is "*" <=> all scholars
sql_query
=
"""
SELECT doors_uid
...
...
@@ -140,7 +143,6 @@ class MyExtractor:
# build constraints from the args
# ================================
filter_dict
=
restparse
(
queryargs
)
sql_constraints
=
[]
for
key
in
filter_dict
:
known_filter
=
None
...
...
@@ -154,20 +156,25 @@ class MyExtractor:
val
=
filter_dict
[
known_filter
]
clause
=
""
if
isinstance
(
val
,
list
)
or
isinstance
(
val
,
tuple
):
qwliststr
=
repr
(
val
)
qwliststr
=
sub
(
r'^\['
,
'('
,
qwliststr
)
qwliststr
=
sub
(
r'\]$'
,
')'
,
qwliststr
)
clause
=
'IN '
+
qwliststr
elif
isinstance
(
val
,
int
):
clause
=
'=
%
i'
%
val
elif
isinstance
(
val
,
float
):
clause
=
'=
%
f'
%
val
elif
isinstance
(
val
,
str
):
clause
=
'= "
%
s"'
%
val
sql_constraints
.
append
(
"(
%
s
%
s)"
%
(
sql_column
,
clause
))
if
len
(
val
):
clause
=
""
if
isinstance
(
val
,
list
)
or
isinstance
(
val
,
tuple
):
tested_array
=
[
x
for
x
in
val
if
x
!=
''
]
print
(
"tested_array"
,
tested_array
)
if
len
(
tested_array
):
qwliststr
=
repr
(
tested_array
)
qwliststr
=
sub
(
r'^\['
,
'('
,
qwliststr
)
qwliststr
=
sub
(
r'\]$'
,
')'
,
qwliststr
)
clause
=
'IN '
+
qwliststr
elif
isinstance
(
val
,
int
):
clause
=
'=
%
i'
%
val
elif
isinstance
(
val
,
float
):
clause
=
'=
%
f'
%
val
elif
isinstance
(
val
,
str
):
clause
=
'= "
%
s"'
%
val
if
len
(
clause
):
sql_constraints
.
append
(
"(
%
s
%
s)"
%
(
sql_column
,
clause
))
# debug
print
(
"sql_constraints"
,
sql_constraints
)
...
...
@@ -198,10 +205,11 @@ class MyExtractor:
"""
%
(
" AND "
.
join
(
sql_constraints
))
self
.
cursor
.
execute
(
sql_query
)
scholar_rows
=
self
.
cursor
.
fetchall
()
for
row
in
scholar_rows
:
scholar_array
[
row
[
'doors_uid'
]
]
=
1
# in both cases "*" or constraints
self
.
cursor
.
execute
(
sql_query
)
scholar_rows
=
self
.
cursor
.
fetchall
()
for
row
in
scholar_rows
:
scholar_array
[
row
[
'doors_uid'
]
]
=
1
return
scholar_array
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment