add option to graph the number of modules touched during a time period

This commit is contained in:
Frédéric Péters 2017-10-14 23:32:15 +02:00
parent b724258f23
commit 52f0db9f95
1 changed files with 17 additions and 4 deletions

View File

@ -11,6 +11,9 @@ class Command(GraphCommand):
super(Command, self).add_arguments(parser)
parser.add_argument('--groupby', metavar='TIME UNIT', default='weeks',
help='aggregate over weeks (default) / months / years')
parser.add_argument('--modulecount', type=int,
help='count number of modules instead of commits '
'(value is minimum number of commits to be counted in)')
def handle(self, *args, **options):
title = 'Git activity'
@ -30,12 +33,22 @@ class Command(GraphCommand):
graph_date = commit_date.replace(month=1, day=1)
date = matplotlib.dates.date2num(graph_date)
if not date in events:
events[date] = 0
events[date] = events[date] + 1
if options.get('modulecount'):
if not date in events:
events[date] = {}
if not commit.module in events[date]:
events[date][commit.module] = 0
events[date][commit.module] += 1
else:
if not date in events:
events[date] = 0
events[date] += 1
dates = sorted(events.keys())
values = [events[x] for x in dates]
if options.get('modulecount'):
values = [len([y for y in events[x].values() if y > options.get('modulecount')]) for x in dates]
else:
values = [events[x] for x in dates]
plt.bar(dates, values, width=20)
plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%m/%Y'))