From bc60cc713b6720e3ddc3610cf9cd7b280df1fc2c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 22 2014 18:27:30 +0000 Subject: Add the get_issues the possibility to retrieve the issues with a specific tag --- diff --git a/progit/lib.py b/progit/lib.py index 16fab5e..a9d98f8 100644 --- a/progit/lib.py +++ b/progit/lib.py @@ -534,13 +534,16 @@ def get_project(session, name, user=None): return query.first() -def get_issues(session, repo, status=None, closed=False): +def get_issues(session, repo, status=None, closed=False, tags=None): ''' Retrieve all the issues associated to a project Watch out that the closed argument is incompatible with the status argument. The closed argument will return all the issues whose status is not 'Open', otherwise it will return the issues having the specified status. + The `tags` argument can be used to filter the issues returned based on + a certain tag. + ''' subquery = session.query( model.GlobalId, @@ -572,6 +575,12 @@ def get_issues(session, repo, status=None, closed=False): query = query.filter( model.Issue.status != 'Open' ) + if tags is not None: + query = query.filter( + model.Issue.id == model.TagIssue.issue_id + ).filter( + model.TagIssue.tag.in_(tags) + ) return query.all()