From f9fa40d813779dbd7769e3a93d3456f30d508037 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Fri, 7 Sep 2007 11:37:21 +0300 Subject: [PATCH] List of Authors: added "# by commits" column. --- doc/TODO.txt | 1 - gitstats | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/TODO.txt b/doc/TODO.txt index 4961600..6da60cc 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -36,7 +36,6 @@ - Authors - (T) List of authors - Lines - - Position by nrof commits - (T) Author of Month - Lines - (T) Author of Year diff --git a/gitstats b/gitstats index e6077fc..90a70fa 100755 --- a/gitstats +++ b/gitstats @@ -32,7 +32,9 @@ def getoutput(cmd, quiet = False): def getkeyssortedbyvalues(dict): return map(lambda el : el[1], sorted(map(lambda el : (el[1], el[0]), dict.items()))) -# TODO getdictkeyssortedbyvaluekey(dict, key) - eg. dict['author'] = { 'commits' : 512 } - ...key(dict, 'commits') +# dict['author'] = { 'commits': 512 } - ...key(dict, 'commits') +def getkeyssortedbyvaluekey(d, key): + return map(lambda el : el[1], sorted(map(lambda el : (d[el][key], el), d.keys()))) class DataCollector: """Manages data collection from a revision control repository.""" @@ -527,10 +529,12 @@ class HTMLReportCreator(ReportCreator): f.write(html_header(2, 'List of Authors')) f.write('') - f.write('') + f.write('') + authors_by_commits = getkeyssortedbyvaluekey(data.authors, 'commits') + authors_by_commits.reverse() # most first for author in sorted(data.getAuthors()): info = data.getAuthorInfo(author) - f.write('' % (author, info['commits'], info['commits_frac'], info['date_first'], info['date_last'], info['timedelta'])) + f.write('' % (author, info['commits'], info['commits_frac'], info['date_first'], info['date_last'], info['timedelta'], authors_by_commits.index(author) + 1)) f.write('
AuthorCommits (%)First commitLast commitAge
AuthorCommits (%)First commitLast commitAge# by commits
%s%d (%.2f%%)%s%s%s
%s%d (%.2f%%)%s%s%s%d
') # Authors :: Author of Month -- 2.11.4.GIT