Преглед изворни кода

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

Can be overriden with -c max_authors=N
Heikki Hokkanen пре 16 година
родитељ
комит
c5cdf5750e
2 измењених фајлова са 16 додато и 4 уклоњено
  1. 12
    4
      gitstats
  2. 4
    0
      gitstats.css

+ 12
- 4
gitstats Прегледај датотеку

@@ -30,7 +30,8 @@ if 'GNUPLOT' in os.environ:
30 30
 conf = {
31 31
 	'max_domains': 10,
32 32
 	'max_ext_length': 10,
33
-	'style': 'gitstats.css'
33
+	'style': 'gitstats.css',
34
+	'max_authors': 20,
34 35
 }
35 36
 
36 37
 def getpipeoutput(cmds, quiet = False):
@@ -455,8 +456,10 @@ class GitDataCollector(DataCollector):
455 456
 	def getAuthorInfo(self, author):
456 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 464
 	def getCommitDeltaDays(self):
462 465
 		return (self.last_commit_stamp - self.first_commit_stamp) / 86400
@@ -768,11 +771,16 @@ class HTMLReportCreator(ReportCreator):
768 771
 
769 772
 		f.write('<table class="authors sortable" id="authors">')
770 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 775
 			info = data.getAuthorInfo(author)
773 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 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 784
 		# Authors :: Author of Month
777 785
 		f.write(html_header(2, 'Author of Month'))
778 786
 		f.write('<table class="sortable" id="aom">')

+ 4
- 0
gitstats.css Прегледај датотеку

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