Skip to content

Commit

Permalink
Merge pull request #227 from devenv/jira_est
Browse files Browse the repository at this point in the history
jira estimate UDA
  • Loading branch information
ralphbean committed Jul 29, 2015
2 parents 89ef3d7 + 2317a05 commit 06adc5b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bugwarrior/docs/services/jira.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ Provided UDA Fields
+---------------------+---------------------+---------------------+
| ``jiraurl`` | URL | Text (string) |
+---------------------+---------------------+---------------------+
| ``jiraestimate`` | Estimate | Decimal (numeric) |
+---------------------+---------------------+---------------------+
14 changes: 14 additions & 0 deletions bugwarrior/services/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JiraIssue(Issue):
URL = 'jiraurl'
FOREIGN_ID = 'jiraid'
DESCRIPTION = 'jiradescription'
ESTIMATE = 'jiraestimate'

UDAS = {
SUMMARY: {
Expand All @@ -30,6 +31,10 @@ class JiraIssue(Issue):
FOREIGN_ID: {
'type': 'string',
'label': 'Jira Issue ID'
},
ESTIMATE: {
'type': 'numeric',
'label': 'Estimate'
}
}
UNIQUE_KEY = (URL, )
Expand All @@ -53,6 +58,7 @@ def to_taskwarrior(self):
self.FOREIGN_ID: self.record['key'],
self.DESCRIPTION: self.record.get('fields', {}).get('description'),
self.SUMMARY: self.get_summary(),
self.ESTIMATE: self.get_estimate(),
}

def get_tags(self):
Expand Down Expand Up @@ -91,6 +97,14 @@ def get_summary(self):
return self.record['fields']['summary']['value']
return self.record['fields']['summary']

def get_estimate(self):
if self.extra.get('jira_version') == 4:
return self.record['fields']['timeestimate']['value']
try:
return self.record['fields']['timeestimate'] / 60 / 60
except (TypeError, KeyError):
return None

def get_priority(self):
value = self.record['fields'].get('priority')
if isinstance(value, dict):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def test_to_taskwarrior(self):
arbitrary_id = '10'
arbitrary_url = 'http://one'
arbitrary_summary = 'lkjaldsfjaldf'
arbitrary_estimation = 3600
arbitrary_record = {
'fields': {
'priority': 'Blocker',
'summary': arbitrary_summary,
'timeestimate': arbitrary_estimation,
},
'key': '%s-%s' % (arbitrary_project, arbitrary_id, ),
}
Expand All @@ -49,6 +51,7 @@ def test_to_taskwarrior(self):
issue.FOREIGN_ID: arbitrary_record['key'],
issue.SUMMARY: arbitrary_summary,
issue.DESCRIPTION: None,
issue.ESTIMATE: arbitrary_estimation / 60 / 60,
}

def get_url(*args):
Expand Down

0 comments on commit 06adc5b

Please sign in to comment.