Skip to content

Commit

Permalink
Pull comments from tasks in as annotations. (work in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
kostajh committed Apr 4, 2014
1 parent db3f6df commit 875bc4a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion bugwarrior/services/activecollab.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def to_taskwarrior(self):
record = {
'project': self.record['project'],
'priority': self.get_priority(),
'annotations': self.extra.get('annotations', []),
self.NAME: self.record.get('name'),
self.BODY: pypandoc.convert(self.record.get('body'),
'md', format='html'),
Expand Down Expand Up @@ -209,6 +210,30 @@ def validate_config(cls, config, target):

IssueService.validate_config(config, target)

def _comments(self, issue):
comments = self.ac.get_comments(issue[u'permalink'].split('/')[4],
issue[u'task_id'])
comments_formatted = []
if comments is not None:
for comment in comments:
comments_formatted.append(
dict(user=comment[u'created_by'][u'display_name'],
body=comment[u'body']))
return comments_formatted

def annotations(self, issue):
if issue[u'type'] is 'subtask':
return []
comments = self._comments(issue)
if comments is None:
return []
return self.build_annotations(
(
c['user'],
pypandoc.convert(c['body'], 'md', format='html'),
) for c in comments
)

def issues(self):
# Loop through each project
start = time.time()
Expand All @@ -229,4 +254,7 @@ def issues(self):
" Elapsed Time: %s" % (time.time() - start))

for record in itertools.chain(*issue_generators):
yield self.get_issue_for_record(record)
extra = {
'annotations': self.annotations(record)
}
yield self.get_issue_for_record(record, extra)

0 comments on commit 875bc4a

Please sign in to comment.