Show weekly activity for last 32 weeks.
This commit is contained in:
parent
5fd64e6c19
commit
3585ce766d
44
gitstats
44
gitstats
@ -159,6 +159,8 @@ class GitDataCollector(DataCollector):
|
||||
self.activity_by_hour_of_week = {} # weekday -> hour -> commits
|
||||
self.activity_by_hour_of_day_busiest = 0
|
||||
self.activity_by_hour_of_week_busiest = 0
|
||||
self.activity_by_year_week = {} # yy_wNN -> commits
|
||||
self.activity_by_year_week_peak = 0
|
||||
|
||||
self.authors = {} # name -> {commits, first_commit_stamp, last_commit_stamp, last_active_day, active_days}
|
||||
|
||||
@ -265,6 +267,15 @@ class GitDataCollector(DataCollector):
|
||||
else:
|
||||
self.activity_by_month_of_year[month] = 1
|
||||
|
||||
# yearly/weekly activity
|
||||
yyw = date.strftime('%Y-%W')
|
||||
if yyw not in self.activity_by_year_week:
|
||||
self.activity_by_year_week[yyw] = 1
|
||||
else:
|
||||
self.activity_by_year_week[yyw] += 1
|
||||
if self.activity_by_year_week_peak < self.activity_by_year_week[yyw]:
|
||||
self.activity_by_year_week_peak = self.activity_by_year_week[yyw]
|
||||
|
||||
# author stats
|
||||
if author not in self.authors:
|
||||
self.authors[author] = {}
|
||||
@ -546,6 +557,39 @@ class HTMLReportCreator(ReportCreator):
|
||||
|
||||
#f.write('<h2>Last 12 months</h2>')
|
||||
|
||||
# Weekly activity
|
||||
WEEKS = 32
|
||||
f.write(html_header(2, 'Weekly activity'))
|
||||
f.write('<p>Last %d weeks</p>' % WEEKS)
|
||||
|
||||
# generate weeks to show (previous N weeks from now)
|
||||
now = datetime.datetime.now()
|
||||
deltaweek = datetime.timedelta(7)
|
||||
weeks = []
|
||||
stampcur = now
|
||||
for i in range(0, WEEKS):
|
||||
weeks.insert(0, stampcur.strftime('%Y-%W'))
|
||||
stampcur -= deltaweek
|
||||
|
||||
# top row: commits & bar
|
||||
f.write('<table class="noborders"><tr>')
|
||||
for i in range(0, WEEKS):
|
||||
commits = 0
|
||||
if weeks[i] in data.activity_by_year_week:
|
||||
commits = data.activity_by_year_week[weeks[i]]
|
||||
|
||||
percentage = 0
|
||||
if weeks[i] in data.activity_by_year_week:
|
||||
percentage = float(data.activity_by_year_week[weeks[i]]) / data.activity_by_year_week_peak
|
||||
height = max(1, int(200 * percentage))
|
||||
f.write('<td style="text-align: center; vertical-align: bottom">%d<div style="display: block; background-color: red; width: 20px; height: %dpx"></div></td>' % (commits, height))
|
||||
|
||||
# bottom row: year/week
|
||||
f.write('</tr><tr>')
|
||||
for i in range(0, WEEKS):
|
||||
f.write('<td>%s</td>' % (WEEKS - i))
|
||||
f.write('</tr></table>')
|
||||
|
||||
# Hour of Day
|
||||
f.write(html_header(2, 'Hour of Day'))
|
||||
hour_of_day = data.getActivityByHourOfDay()
|
||||
|
@ -28,6 +28,14 @@ table {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
table.noborders {
|
||||
border: none;
|
||||
}
|
||||
|
||||
table.noborders td {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.vtable {
|
||||
float: right;
|
||||
clear: both;
|
||||
|
Loading…
x
Reference in New Issue
Block a user