From 6cd6a9dd9d650e1d8ecd784059f0024c33342106 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 20 2015 12:43:42 +0000 Subject: Add the possibility to filter issues for issue not having a specific tag If you want to filter all the issues not having `tag` then filter for `!tag`, it will return the list of issues not having this tag. --- diff --git a/progit/lib/__init__.py b/progit/lib/__init__.py index 2e70001..a16e959 100644 --- a/progit/lib/__init__.py +++ b/progit/lib/__init__.py @@ -776,12 +776,32 @@ def search_issues( if tags is not None and tags != []: if isinstance(tags, basestring): tags = [tags] + notags = [] + ytags = [] + for tag in tags: + if tag.startswith('!'): + notags.append(tag[1:]) + else: + ytags.append(tag) + + if ytags: + query = query.filter( + model.Issue.uid == model.TagIssue.issue_uid + ).filter( + model.TagIssue.tag.in_(ytags) + ) + if notags: + sub = session.query( + model.Issue.uid + ).filter( + model.Issue.uid == model.TagIssue.issue_uid + ).filter( + model.TagIssue.tag.in_(notags) + ) - query = query.filter( - model.Issue.uid == model.TagIssue.issue_uid - ).filter( - model.TagIssue.tag.in_(tags) - ) + query = query.filter( + ~model.Issue.uid.in_(sub) + ) if assignee is not None: if str(assignee).lower() not in ['false', '0', 'true', '1']: user2 = aliased(model.User)