-
Notifications
You must be signed in to change notification settings - Fork 3
/
commit_histogram.py
65 lines (47 loc) · 1.8 KB
/
commit_histogram.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
60
61
62
63
64
65
from anvil import Anvil
import datetime
import functools
import threading
import times
from matplotlib import pyplot as pp
START_DT = datetime.datetime(2011, 11, 1)
def find_changesets_for_authors(anvil, authors, start_dt,
end_dt=datetime.datetime.now()):
"""parallel search for changesets by some set of users in a date range"""
repos = anvil.get_repos()
kiln_start_date = start_dt.strftime("%m/%d/%Y")
kiln_end_date = end_dt.strftime("%m/%d/%Y")
results = {}
def compute_and_store(repo, person, start_date, end_date):
result = repo.search_changesets(
'edited:"{}:{}" author:"{}"'.format(kiln_start_date, kiln_end_date, person))
results[(repo, person)] = result
computations = []
for repo in repos:
for person in authors:
f = functools.partial(compute_and_store,
repo, person, "11/1/11", "4/6/12")
computations.append(f)
threads = [threading.Thread(target=computation)
for computation in computations]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
changesets_by_author = {}
for (repo, author), changesets in results.items():
changesets_by_author.setdefault(author, []).extend(changesets)
return changesets_by_author
def main():
anvil = Anvil("spectrum")
anvil.create_session_by_prompting()
print "collecting related changesets"
changesets = find_changesets_for_authors(
anvil, ['Paul Osborne', ], datetime.datetime(2009, 1, 1)).values()[0]
commit_hour = [times.to_local(c.date_time, 'US/Central').hour for c in changesets]
pp.hist(commit_hour, 24)
a = pp.gca()
a.set_xlim([0, 23])
pp.show()
if __name__ == '__main__':
main()