Browse Source

Limit author table to 20, and list only name for rest.

Can be overriden with -c max_authors=N
Heikki Hokkanen 16 years ago
parent
commit
c5cdf5750e
2 changed files with 16 additions and 4 deletions
  1. 12
    4
      gitstats
  2. 4
    0
      gitstats.css

+ 12
- 4
gitstats View File

30
 conf = {
30
 conf = {
31
 	'max_domains': 10,
31
 	'max_domains': 10,
32
 	'max_ext_length': 10,
32
 	'max_ext_length': 10,
33
-	'style': 'gitstats.css'
33
+	'style': 'gitstats.css',
34
+	'max_authors': 20,
34
 }
35
 }
35
 
36
 
36
 def getpipeoutput(cmds, quiet = False):
37
 def getpipeoutput(cmds, quiet = False):
455
 	def getAuthorInfo(self, author):
456
 	def getAuthorInfo(self, author):
456
 		return self.authors[author]
457
 		return self.authors[author]
457
 	
458
 	
458
-	def getAuthors(self):
459
-		return self.authors.keys()
459
+	def getAuthors(self, limit = None):
460
+		res = getkeyssortedbyvaluekey(self.authors, 'commits')
461
+		res.reverse()
462
+		return res[:limit]
460
 	
463
 	
461
 	def getCommitDeltaDays(self):
464
 	def getCommitDeltaDays(self):
462
 		return (self.last_commit_stamp - self.first_commit_stamp) / 86400
465
 		return (self.last_commit_stamp - self.first_commit_stamp) / 86400
768
 
771
 
769
 		f.write('<table class="authors sortable" id="authors">')
772
 		f.write('<table class="authors sortable" id="authors">')
770
 		f.write('<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
773
 		f.write('<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
771
-		for author in sorted(data.getAuthors()):
774
+		for author in sorted(data.getAuthors(conf['max_authors'])):
772
 			info = data.getAuthorInfo(author)
775
 			info = data.getAuthorInfo(author)
773
 			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author, info['commits'], info['commits_frac'], info['lines_added'], info['lines_removed'], info['date_first'], info['date_last'], info['timedelta'], info['active_days'], info['place_by_commits']))
776
 			f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author, info['commits'], info['commits_frac'], info['lines_added'], info['lines_removed'], info['date_first'], info['date_last'], info['timedelta'], info['active_days'], info['place_by_commits']))
774
 		f.write('</table>')
777
 		f.write('</table>')
775
 
778
 
779
+		allauthors = data.getAuthors()
780
+		if len(allauthors) > conf['max_authors']:
781
+			rest = allauthors[conf['max_authors']:]
782
+			f.write('<p class="moreauthors">These didn\'t make it to the top: %s</p>' % ', '.join(rest))
783
+
776
 		# Authors :: Author of Month
784
 		# Authors :: Author of Month
777
 		f.write(html_header(2, 'Author of Month'))
785
 		f.write(html_header(2, 'Author of Month'))
778
 		f.write('<table class="sortable" id="aom">')
786
 		f.write('<table class="sortable" id="aom">')

+ 4
- 0
gitstats.css View File

135
 h2 a {
135
 h2 a {
136
 	color: white;
136
 	color: white;
137
 }
137
 }
138
+
139
+.moreauthors {
140
+	font-size: 80%;
141
+}