github: don't fetch comments when iterating issues
This commit is contained in:
parent
d91dc46a87
commit
3f8169a672
2 changed files with 16 additions and 9 deletions
|
|
@ -66,7 +66,14 @@ class GithubBackend(BaseBackend, ICapBugTracker):
|
|||
def get_issue(self, _id):
|
||||
project_id, issue_number = _id.rsplit('/', 1)
|
||||
project = self.get_project(project_id)
|
||||
return self._make_issue(self.browser.get_issue(project_id, issue_number), project)
|
||||
|
||||
d = self.browser.get_issue(project_id, issue_number)
|
||||
|
||||
issue = self._make_issue(d, project)
|
||||
if d['has_comments']:
|
||||
self._fetch_comments(issue)
|
||||
|
||||
return issue
|
||||
|
||||
def iter_issues(self, query):
|
||||
if ((query.assignee, query.author, query.status, query.title) ==
|
||||
|
|
@ -131,11 +138,14 @@ class GithubBackend(BaseBackend, ICapBugTracker):
|
|||
|
||||
issue.attachments = [self._make_attachment(dattach) for dattach in d['attachments']]
|
||||
|
||||
issue.history = []
|
||||
issue.history += [self._make_comment(dcomment, project) for dcomment in d['comments']]
|
||||
|
||||
return issue
|
||||
|
||||
def _fetch_comments(self, issue):
|
||||
project_id, issue_number = self._extract_issue_id(issue.id)
|
||||
if not issue.history:
|
||||
issue.history = []
|
||||
issue.history += [self._make_comment(dcomment, issue.project) for dcomment in self.browser.iter_comments(project_id, issue_number)]
|
||||
|
||||
def _make_attachment(self, d):
|
||||
a = Attachment(d['url'])
|
||||
a.url = d['url']
|
||||
|
|
|
|||
|
|
@ -112,10 +112,7 @@ class GithubBrowser(BaseBrowser):
|
|||
d['version'] = json['milestone']
|
||||
else:
|
||||
d['version'] = None
|
||||
if json['comments'] > 0:
|
||||
d['comments'] = list(self.get_comments(project_id, issue_number))
|
||||
else:
|
||||
d['comments'] = []
|
||||
d['has_comments'] = (json['comments'] > 0)
|
||||
d['attachments'] = list(self._extract_attachments(d['body']))
|
||||
|
||||
# TODO fetch other updates?
|
||||
|
|
@ -125,7 +122,7 @@ class GithubBrowser(BaseBrowser):
|
|||
for jmilestone in self.do_get('https://api.github.com/repos/%s/milestones' % project_id):
|
||||
yield {'id': jmilestone['number'], 'name': jmilestone['title']}
|
||||
|
||||
def get_comments(self, project_id, issue_number):
|
||||
def iter_comments(self, project_id, issue_number):
|
||||
json = self.do_get('https://api.github.com/repos/%s/issues/%s/comments' % (project_id, issue_number))
|
||||
for jcomment in json:
|
||||
d = {'id': jcomment['id'], 'message': jcomment['body'], 'author': jcomment['user']['login'], 'date': parse_date(jcomment['created_at'])}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue