Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.db.kboc16
Commits
4cd9233f
Commit
4cd9233f
authored
Feb 08, 2016
by
mgbarrero
Browse files
fixes on queries models
parent
82ec5716
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/db/kboc16/query.py
View file @
4cd9233f
...
...
@@ -59,7 +59,7 @@ class Database(bob.db.verification.utils.SQLiteDatabase,bob.db.verification.util
return
ProtocolPurpose
.
group_choices
def
clients
(
self
,
protocol
=
None
,
groups
=
None
):
def
clients
(
self
,
protocol
=
None
,
groups
=
'eval'
):
"""Returns a list of :py:class:`.Client` for the specific query by the user.
Keyword Parameters:
...
...
@@ -78,7 +78,11 @@ class Database(bob.db.verification.utils.SQLiteDatabase,bob.db.verification.util
"""groups = self.__group_replace_eval_by_genuine__(groups)
groups = self.check_parameters_for_validity(groups, "group", self.client_groups())"""
# List of the clients
q
=
self
.
query
(
Client
)
#q = self.query(Client)
if
(
protocol
):
q
=
self
.
query
(
Client
).
join
(
File
).
join
((
ProtocolPurpose
,
File
.
protocolPurposes
)).
join
(
Protocol
).
filter
(
and_
(
Protocol
.
name
.
in_
((
protocol
,)),
ProtocolPurpose
.
sgroup
.
in_
((
groups
,))))
else
:
q
=
self
.
query
(
Client
)
"""if groups:
q = q.filter(Client.sgroup.in_(groups))"""
q
=
q
.
order_by
(
Client
.
id
)
...
...
bob/db/kboc16/test.py
View file @
4cd9233f
...
...
@@ -27,6 +27,10 @@ class kboc16DatabaseTest(unittest.TestCase):
assert
len
(
db
.
groups
())
==
1
assert
len
(
db
.
clients
())
==
300
assert
len
(
db
.
clients
(
groups
=
'eval'
))
==
300
assert
len
(
db
.
clients
(
protocol
=
'A'
,
groups
=
'eval'
))
==
300
assert
len
(
db
.
clients
(
protocol
=
'A'
))
==
300
assert
len
(
db
.
clients
(
protocol
=
'D'
,
groups
=
'eval'
))
==
100
assert
len
(
db
.
clients
(
protocol
=
'D'
))
==
100
assert
len
(
db
.
models
())
==
300
assert
len
(
db
.
models
(
groups
=
'eval'
))
==
300
assert
len
(
db
.
models
(
protocol
=
'A'
,
groups
=
'eval'
))
==
300
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment