From 77e16c90c32f6602b8e6a98275d464413dedd85f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 04 2014 10:26:29 +0000 Subject: Retrieve the global identifiers when retrieving the list of issues of a project --- diff --git a/progit/lib.py b/progit/lib.py index fb7f8a6..9876b5a 100644 --- a/progit/lib.py +++ b/progit/lib.py @@ -355,10 +355,22 @@ def get_issues(session, repo, status=None, closed=False): is not 'Open', otherwise it will return the issues having the specified status. ''' + subquery = session.query( + model.GlobalId, + sqlalchemy.over( + sqlalchemy.func.row_number(), + partition_by=model.GlobalId.project_id, + order_by=model.GlobalId.id + ).label('global_id') + ).subquery() + query = session.query( - model.Issue + model.Issue, + subquery.c.global_id + ).filter( + subquery.c.issue_id == model.Issue.id ).filter( - model.Issue.project_id == repo.id + subquery.c.project_id == model.Issue.project_id ) if status is not None and not closed: