From d907dc28e7d223924783ee17a00e34132f1eb676 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 2 Aug 2007 20:43:03 +0300 Subject: [PATCH] Authors: Author of Year. --- TODO.txt | 2 +- statgit | 22 ++++++++++++++++++++-- statgit.css | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/TODO.txt b/TODO.txt index 55fca59..4308997 100644 --- a/TODO.txt +++ b/TODO.txt @@ -29,7 +29,7 @@ - List of authors - show only first 10 and rest on separate page? - DONE (T): author, commits (%), LOC?, first commit, last commit - - (T): Developer of the Month: month, author, commits, LOC? + - DONE (T): Developer of the Month: month, author, commits, LOC? - Files - Total Files diff --git a/statgit b/statgit index 26a51b9..d5dad74 100755 --- a/statgit +++ b/statgit @@ -94,6 +94,7 @@ class GitDataCollector(DataCollector): # TODO author of the month self.author_of_month = {} # month -> author -> commits + self.author_of_year = {} # year -> author -> commits self.commits_by_month = {} # month -> commits lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n') @@ -103,7 +104,7 @@ class GitDataCollector(DataCollector): author = ' '.join(parts[1:]) yymm = datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m') - if yymm in self.author_of_month and author in self.author_of_month[yymm]: + if yymm in self.author_of_month: if author in self.author_of_month[yymm]: self.author_of_month[yymm][author] += 1 else: @@ -116,6 +117,16 @@ class GitDataCollector(DataCollector): else: self.commits_by_month[yymm] = 1 + yy = datetime.datetime.fromtimestamp(stamp).year + if yy in self.author_of_year: + if author in self.author_of_year[yy]: + self.author_of_year[yy][author] += 1 + else: + self.author_of_year[yy][author] = 1 + else: + self.author_of_year[yy] = {} + self.author_of_year[yy][author] = 1 + print self.author_of_month def getActivityByDayOfWeek(self): @@ -284,7 +295,14 @@ class HTMLReportCreator(ReportCreator): f.write('') f.write('\n

Author of Year

\n\n') - # TODO + f.write('') + for yy in reversed(sorted(data.author_of_year.keys())): + authordict = data.author_of_year[yy] + authors = getkeyssortedbyvalues(authordict) + authors.reverse() + commits = data.author_of_year[yy][authors[0]] + f.write('' % (yy, authors[0], commits)) + f.write('
YearAuthorCommits (%)
%s%s%d
') f.write('') f.close() diff --git a/statgit.css b/statgit.css index d3c1823..b26fd23 100644 --- a/statgit.css +++ b/statgit.css @@ -18,3 +18,26 @@ dd { clear: right; } +table { + border: 1px solid black; + border-collapse: collapse; +} + +tr { +} + +th { + background-color: #eeb; +} + +tr:hover { + background-color: #dda; +} + +td { + border: 1px solid black; + padding: 0.2em; + padding-left: 0.5em; + padding-right: 0.5em; +} + -- 2.11.4.GIT