Kaynağa Gözat

Authors: Author of Year.

Heikki Hokkanen 18 yıl önce
ebeveyn
işleme
d907dc28e7
3 değiştirilmiş dosya ile 44 ekleme ve 3 silme
  1. 1
    1
      TODO.txt
  2. 20
    2
      statgit
  3. 23
    0
      statgit.css

+ 1
- 1
TODO.txt Dosyayı Görüntüle

@@ -29,7 +29,7 @@
29 29
 	- List of authors
30 30
 		- show only first 10 and rest on separate page?
31 31
 	- DONE (T): author, commits (%), LOC?, first commit, last commit
32
-	- (T): Developer of the Month: month, author, commits, LOC?
32
+	- DONE (T): Developer of the Month: month, author, commits, LOC?
33 33
 
34 34
 - Files
35 35
 	- Total Files

+ 20
- 2
statgit Dosyayı Görüntüle

@@ -94,6 +94,7 @@ class GitDataCollector(DataCollector):
94 94
 
95 95
 		# TODO author of the month
96 96
 		self.author_of_month = {} # month -> author -> commits
97
+		self.author_of_year = {} # year -> author -> commits
97 98
 		self.commits_by_month = {} # month -> commits
98 99
 
99 100
 		lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n')
@@ -103,7 +104,7 @@ class GitDataCollector(DataCollector):
103 104
 			author = ' '.join(parts[1:])
104 105
 
105 106
 			yymm = datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m')
106
-			if yymm in self.author_of_month and author in self.author_of_month[yymm]:
107
+			if yymm in self.author_of_month:
107 108
 				if author in self.author_of_month[yymm]:
108 109
 					self.author_of_month[yymm][author] += 1
109 110
 				else:
@@ -116,6 +117,16 @@ class GitDataCollector(DataCollector):
116 117
 			else:
117 118
 				self.commits_by_month[yymm] = 1
118 119
 
120
+			yy = datetime.datetime.fromtimestamp(stamp).year
121
+			if yy in self.author_of_year:
122
+				if author in self.author_of_year[yy]:
123
+					self.author_of_year[yy][author] += 1
124
+				else:
125
+					self.author_of_year[yy][author] = 1
126
+			else:
127
+				self.author_of_year[yy] = {}
128
+				self.author_of_year[yy][author] = 1
129
+
119 130
 		print self.author_of_month
120 131
 	
121 132
 	def getActivityByDayOfWeek(self):
@@ -284,7 +295,14 @@ class HTMLReportCreator(ReportCreator):
284 295
 		f.write('</table>')
285 296
 
286 297
 		f.write('\n<h2>Author of Year</h2>\n\n')
287
-		# TODO
298
+		f.write('<table><tr><th>Year</th><th>Author</th><th>Commits (%)</th></tr>')
299
+		for yy in reversed(sorted(data.author_of_year.keys())):
300
+			authordict = data.author_of_year[yy]
301
+			authors = getkeyssortedbyvalues(authordict)
302
+			authors.reverse()
303
+			commits = data.author_of_year[yy][authors[0]]
304
+			f.write('<tr><td>%s</td><td>%s</td><td>%d</td></tr>' % (yy, authors[0], commits))
305
+		f.write('</table>')
288 306
 
289 307
 		f.write('</body></html>')
290 308
 		f.close()

+ 23
- 0
statgit.css Dosyayı Görüntüle

@@ -18,3 +18,26 @@ dd {
18 18
 	clear: right;
19 19
 }
20 20
 
21
+table {
22
+	border: 1px solid black;
23
+	border-collapse: collapse;
24
+}
25
+
26
+tr {
27
+}
28
+
29
+th {
30
+	background-color: #eeb;
31
+}
32
+
33
+tr:hover {
34
+	background-color: #dda;
35
+}
36
+
37
+td {
38
+	border: 1px solid black;
39
+	padding: 0.2em;
40
+	padding-left: 0.5em;
41
+	padding-right: 0.5em;
42
+}
43
+