Skip to content

Commit

Permalink
Add option to filter tests with warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Maor Marcus committed Jan 20, 2020
1 parent d3ebef8 commit a23d1b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flask_app/blueprints/rest.py
Expand Up @@ -128,6 +128,9 @@ def _get_iterator(self):
args.session_id = request.view_args.get('session_id')

if args.search:
search_tokens = args.search.split()
if 'has_warnings' in search_tokens and args.session_id is None:
abort(requests.codes.forbidden)
returned = get_orm_query_from_search_string('test', args.search, abort_on_syntax_error=True)
else:
returned = super(TestResource, self)._get_iterator().join(Session, Session.id == Test.session_id)
Expand Down
2 changes: 2 additions & 0 deletions flask_app/search/logic.py
Expand Up @@ -130,6 +130,8 @@ def get_base_query(self):

def get_fallback_filter(self, term):
query = TestInformation.name.contains(term)
if term == "has_warnings":
query = query | (Test.num_warnings > 0)
if term == "starred" and current_user and current_user.is_authenticated:
query = query | db.session.query(UserStarredTests).filter(UserStarredTests.user_id == current_user.id, UserStarredTests.test_id == Test.id).exists().correlate(Test)
return query
Expand Down
4 changes: 4 additions & 0 deletions webapp/app/session/index/template.hbs
Expand Up @@ -33,6 +33,10 @@
<td><code>starred</code></td>
<td>Find tests which the current user marked as starred</td>
</tr>
<tr>
<td><code>has_warnings</code></td>
<td>Find tests that has warnings</td>
</tr>
</tbody>
</table>
{{/search-bar}}
Expand Down

0 comments on commit a23d1b2

Please sign in to comment.