From c696cfa086cda43126b69a1ae34e2211ea64d2f2 Mon Sep 17 00:00:00 2001 From: Vincent A Date: Fri, 1 Nov 2013 18:24:49 +0100 Subject: [PATCH] github: lighter iter_issues if repo is the only query criterion --- modules/github/backend.py | 8 +++++++- modules/github/browser.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/github/backend.py b/modules/github/backend.py index 237656ae..62f9d564 100644 --- a/modules/github/backend.py +++ b/modules/github/backend.py @@ -55,7 +55,13 @@ class GithubBackend(BaseBackend, ICapBugTracker): return self.browser.get_issue(_id) def iter_issues(self, query): - for issue in self.browser.iter_issues(query): + if ((query.assignee, query.author, query.status, query.title) == + (None, None, None, None)): + it = self.browser.iter_project_issues(query.project) + else: + it = self.browser.iter_issues(query) + + for issue in it: yield issue def create_issue(self, project_id): diff --git a/modules/github/browser.py b/modules/github/browser.py index 79bbe6b0..1aaf2ebd 100644 --- a/modules/github/browser.py +++ b/modules/github/browser.py @@ -63,6 +63,15 @@ class GithubBrowser(BaseBrowser): json = self.do_get('https://api.github.com/repos/%s/issues/%s' % (project_id, issue_number)) return self.make_issue(_id, json, fetch_project) + def iter_project_issues(self, project_id): + base_url = 'https://api.github.com/repos/%s/issues' % project_id + for json in self._paginated(base_url): + for jissue in json: + issue_id = '%s/%s' % (project_id, jissue['number']) + yield self.make_issue(issue_id, jissue) + if len(json) < 100: + break + def iter_issues(self, query): qsparts = ['repo:%s' % query.project] if query.assignee: