mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
files by date chart
This commit is contained in:
parent
290618b167
commit
d4a144066c
3 changed files with 23 additions and 4 deletions
|
@ -10,8 +10,8 @@ module GitStats
|
|||
@repo = repo
|
||||
end
|
||||
|
||||
def h
|
||||
@h ||= LazyHighCharts::HighChart.new('graph') do |f|
|
||||
def by_wday
|
||||
@by_wday ||= LazyHighCharts::HighChart.new('graph') do |f|
|
||||
f.chart(type: "column")
|
||||
f.title(text: "Commits")
|
||||
f.xAxis(categories: Date::ABBR_DAYNAMES)
|
||||
|
@ -27,10 +27,28 @@ module GitStats
|
|||
shadow: true
|
||||
)
|
||||
repo.authors.each do |email, author|
|
||||
f.series(:name => email, :data => author.activity.by_wday.inject([]) { |acc, (k, v)| acc[k] = v; acc })
|
||||
f.series(name: email, data: author.activity.by_wday.inject([]) { |acc, (k, v)| acc[k] = v; acc })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def files_by_date
|
||||
@files_by_date ||= LazyHighCharts::HighChart.new('graph') do |f|
|
||||
f.title(text: "Files")
|
||||
f.xAxis(type: "datetime")
|
||||
f.yAxis(min: 0, title: {text: 'Commits'})
|
||||
rcommits = repo.commits.reverse
|
||||
f.series(
|
||||
type: "area",
|
||||
name: "commits",
|
||||
pointInterval: 1.day * 1000,
|
||||
pointStart: repo.commits.first.date.to_i * 1000,
|
||||
data: repo.commits.first.date.midnight.upto((repo.commits.last.date + 1.day).midnight).map { |day|
|
||||
rcommits.find { |c| c.date < day }.files_count rescue 0
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1 +1 @@
|
|||
= high_chart("my_id", h)
|
||||
= high_chart("by_wday", by_wday)
|
1
templates/files.haml
Normal file
1
templates/files.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= high_chart("files_by_date", files_by_date)
|
Loading…
Reference in a new issue