From e5fc428ecf3b23ed6b1a640bbddff9a59b251969 Mon Sep 17 00:00:00 2001 From: "Wulf C. Krueger" Date: Sun, 10 Jan 2010 00:34:05 +0100 Subject: [PATCH] Add a graph for commits per domain. Signed-off-by: Heikki Hokkanen --- gitstats | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/gitstats b/gitstats index d3a5e32..3822a8d 100755 --- a/gitstats +++ b/gitstats @@ -104,6 +104,10 @@ class DataCollector: def getActivityByHourOfDay(self): return {} + # : get a dictionary of domains + def getDomainInfo(self, domain): + return None + ## # Get a list of authors def getAuthors(self): @@ -164,6 +168,9 @@ class GitDataCollector(DataCollector): self.authors = {} # name -> {commits, first_commit_stamp, last_commit_stamp, last_active_day, active_days, lines_added, lines_removed} + # domains + self.domains = {} # domain -> commits + # author of the month self.author_of_month = {} # month -> author -> commits self.author_of_year = {} # year -> author -> commits @@ -221,7 +228,7 @@ class GitDataCollector(DataCollector): # Collect revision statistics # Outputs " " - lines = getpipeoutput(['git rev-list --pretty=format:"%at %ai %an" HEAD', 'grep -v ^commit']).split('\n') + lines = getpipeoutput(['git rev-list --pretty=format:"%at %ai %aE %an" HEAD', 'grep -v ^commit']).split('\n') for line in lines: parts = line.split(' ') author = '' @@ -230,8 +237,9 @@ class GitDataCollector(DataCollector): except ValueError: stamp = 0 timezone = parts[3] - if len(parts) > 4: - author = ' '.join(parts[4:]) + domain = parts[4].rsplit('@', 1)[1] + if len(parts) > 5: + author = ' '.join(parts[5:]) date = datetime.datetime.fromtimestamp(float(stamp)) # First and last commit stamp @@ -251,6 +259,12 @@ class GitDataCollector(DataCollector): day = date.weekday() self.activity_by_day_of_week[day] = self.activity_by_day_of_week.get(day, 0) + 1 + # domain stats + if domain not in self.domains: + self.domains[domain] = {} + # commits + self.domains[domain]['commits'] = self.domains[domain].get('commits', 0) + 1 + # hour of week if day not in self.activity_by_hour_of_week: self.activity_by_hour_of_week[day] = {} @@ -437,6 +451,12 @@ class GitDataCollector(DataCollector): def getCommitDeltaDays(self): return (self.last_commit_stamp - self.first_commit_stamp) / 86400 + + def getDomainInfo(self, domain): + return self.domains[domain] + + def getDomains(self): + return self.domains.keys() def getFilesInCommit(self, rev): try: @@ -636,6 +656,27 @@ class HTMLReportCreator(ReportCreator): f.write('Day of Week') fp.close() + # Domains + f.write(html_header(2, 'Commits by Domains')) + domains_by_commits = getkeyssortedbyvaluekey(data.domains, 'commits') + domains_by_commits.reverse() # most first + f.write('
') + f.write('') + fp = open(path + '/domains.dat', 'w') + n = 0 + max_domains = 10 + for domain in domains_by_commits: + if n == max_domains: + break + commits = 0 + n += 1 + info = data.getDomainInfo(domain) + fp.write('%s %d %d\n' % (domain, n , info['commits'])) + f.write('' % (domain, info['commits'], (100.0 * info['commits'] / totalcommits))) + f.write('
DomainsTotal (%)
%s%d (%.2f%%)
') + f.write('Commits by Domains') + fp.close() + # Hour of Week f.write(html_header(2, 'Hour of Week')) f.write('') @@ -889,6 +930,20 @@ plot 'day_of_week.dat' using 1:2:(0.5) w boxes fs solid """) f.close() + # Domains + f = open(path + '/domains.plot', 'w') + f.write(GNUPLOT_COMMON) + f.write( +""" +set output 'domains.png' +unset key +unset xtics +set grid y +set ylabel "Commits" +plot 'domains.dat' using 2:3:(0.5) with boxes fs solid, '' using 2:3:1 with labels rotate by 45 offset 0,1 +""") + f.close() + # Month of Year f = open(path + '/month_of_year.plot', 'w') f.write(GNUPLOT_COMMON) -- 2.11.4.GIT