Skip to content

Commit

Permalink
Filtering by the optinal attribute without any defined value considered
Browse files Browse the repository at this point in the history
  • Loading branch information
luav committed Jun 1, 2018
1 parent efb29e0 commit 74f6e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion mpewui.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ def __init__(self, qdict):
self.fltopts[k] = val
else:
# Filter meaning: the option should present with any (non-None) value
if k[-1] == '*':
assert False, 'Only defined attributes can be optional: ' + k
k = k[:-1]
self.fltopts[k] = None
# # Fetch the kind of items to be shown
# self.kind = qdict.get(UiResOpt.kind.name) #pylint: disable=E1101
Expand Down Expand Up @@ -460,7 +463,7 @@ def root(cmd):
# Parse URL parameters and form the UI command parameters
try:
resopts = ResultOptions(bottle.request.query)
except (KeyError, ValueError) as err:
except (KeyError, ValueError, AssertionError) as err:
# 400 - Bad Request
# 415 - Unsupported Media Type
bottle.response.status = 400
Expand Down
4 changes: 2 additions & 2 deletions views/restapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
<p>Query <strong>examples</strong>:
<ul>
<li>
Show tasks with their jobs having <var>rcode=-15</var> if exists, <var>1.5 sec &le; duration &lt; 3600 sec</var> and <var>category</var> attribute might present with any value:
Show tasks with their jobs having <var>rcode=-15</var> if exists, <var>1.5 sec &le; duration &lt; 3600 sec</var> and <var>cat1 &le; category &lt; cat5 </var> if exists:
<pre>
http://localhost:8080/tasks?flt=rcode*:-15|duration:1.5..3600|category*
http://localhost:8080/tasks?flt=rcode*:-15|duration:1.5..3600|category*=cat1..cat5
</pre>
</li>
<li>
Expand Down

0 comments on commit 74f6e01

Please sign in to comment.