From b6df7de5cc164e5f6ba4d11e77dd451c886faa8d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 24 2014 16:03:46 +0000 Subject: Add a generic 'closed' boolean to the get_issues method in the API --- diff --git a/progit/lib.py b/progit/lib.py index caf579e..bb4a196 100644 --- a/progit/lib.py +++ b/progit/lib.py @@ -217,8 +217,13 @@ def get_project(session, name, user=None): return query.first() -def get_issues(session, repo, status=None): +def get_issues(session, repo, status=None, closed=False): ''' 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. ''' query = session.query( model.Issue @@ -226,10 +231,14 @@ def get_issues(session, repo, status=None): model.Issue.project_id == repo.id ) - if status is not None: + if status is not None and not closed: query = query.filter( model.Issue.status == status ) + if closed: + query = query.filter( + model.Issue.status != 'Open' + ) return query.all()