diff --git a/eodb/events/management/commands/activity.py b/eodb/events/management/commands/activity.py index 71ea23c..ab694d3 100644 --- a/eodb/events/management/commands/activity.py +++ b/eodb/events/management/commands/activity.py @@ -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'))