-
Notifications
You must be signed in to change notification settings - Fork 1
/
worklogs_by_dev.py
executable file
·59 lines (47 loc) · 1.67 KB
/
worklogs_by_dev.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
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
#-W ignore::DeprecationWarning
# Suppress all deprecation warnings (not recommended for development)
import warnings
warnings.simplefilter('ignore', DeprecationWarning)
import sys
from jirareports.common import JiraConnection
import datetime as datetime_m
def usage():
print >> sys.stderr, "%s version [date]" % __file__
if len(sys.argv) < 2:
usage()
sys.exit(1)
jira = JiraConnection()
(auth, client, project_name, to_datetime) = (jira.auth, jira.client, jira.project_name, jira.to_datetime)
version = sys.argv[1]
if len(sys.argv) > 2:
release_date = datetime_m.datetime.strptime(sys.argv[2], '%Y-%m-%d')
else:
versions = client.getVersions(auth, project_name)
release_date = None
for v in versions:
if v.name == version:
release_date = jira.to_datetime(*v.releaseDate)
break
if not release_date:
print "Can not find version", version
exit(1)
print "Release date:", release_date
issues = client.getIssuesFromJqlSearch(auth, 'project = %s and fixVersion = %s' % (project_name, version),
jira.int_arg(1000))
print "Worklogs done after sprint is finished:"
stats = {}
for issue in issues:
worklogs = client.getWorklogs(auth, issue.key)
for l in worklogs:
if l.author not in stats:
stats[l.author] = 0
wl_time = jira.to_datetime(*l.created)
if wl_time > release_date:
print "Issue: ", issue
print "Worklog: ", l
if wl_time <= release_date or len(sys.argv) < 3:
stats[l.author] += l.timeSpentInSeconds
print "Work logged by engineer"
for (author, time) in stats.items():
print author, time / 3600.0