-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira_story_point_calculator.py
50 lines (36 loc) · 1.22 KB
/
jira_story_point_calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import argparse
import datetime
from conf import Conf
from jira_service import JiraService
CONF = Conf.get_conf()
def _calc_story_points(issues):
total_points = 0.0
for issue in issues:
sp = issue['fields'].get(CONF['story-point-key'])
if sp: total_points += sp
return total_points
def main():
parser = argparse.ArgumentParser(description='Get data from jira '
'calculate story points')
parser.add_argument('--week', action='store_true',
help='calculate this week\'s points')
parser.add_argument('--month', action='store_true',
help='calculate this month\'s points')
args = parser.parse_args()
today = datetime.date.today()
start_date = None
end_date = None
if args.week:
start_date = (today - datetime.timedelta(
days=today.weekday())).isoformat()
if args.month:
start_date = today.replace(day=1).isoformat()
jira_service = JiraService()
issues = jira_service.get_issues(
start_date=start_date,
end_date=None
)
story_points = _calc_story_points(issues)
print(story_points)
if __name__ == '__main__':
main()