2012-10-20 00:30:00 +02:00
|
|
|
module GitStats
|
|
|
|
module StatsView
|
|
|
|
module Charts
|
|
|
|
class RepoCharts
|
|
|
|
def initialize(repo)
|
|
|
|
@repo = repo
|
|
|
|
end
|
|
|
|
|
2012-10-21 23:11:37 +02:00
|
|
|
[:lines, :files].each do |type|
|
|
|
|
define_method "#{type}_by_extension" do
|
|
|
|
Chart.new do |f|
|
|
|
|
f.column_hash_chart(
|
|
|
|
data: @repo.send("#{type}_by_extension_count"),
|
|
|
|
title: "#{type}_extension".to_sym.t,
|
|
|
|
y_text: type.to_sym.t
|
|
|
|
)
|
|
|
|
end
|
2012-10-20 00:30:00 +02:00
|
|
|
end
|
|
|
|
|
2012-10-21 23:11:37 +02:00
|
|
|
define_method "#{type}_by_date" do
|
|
|
|
Chart.new do |f|
|
|
|
|
f.date_chart(
|
|
|
|
data: @repo.send("#{type}_count_by_date"),
|
|
|
|
title: "#{type}_by_date".to_sym.t,
|
|
|
|
y_text: type.to_sym.t
|
|
|
|
)
|
|
|
|
end
|
2012-10-20 00:30:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-21 23:03:41 +02:00
|
|
|
[:commits_count_by_author, :insertions_by_author, :deletions_by_author].each do |method|
|
2012-10-20 22:41:50 +02:00
|
|
|
define_method method do
|
|
|
|
Chart.new do |f|
|
|
|
|
f.column_hash_chart(
|
|
|
|
data: Hash[@repo.send(method).map { |a, l| [a.email, l] }],
|
|
|
|
title: method.t,
|
2012-10-21 17:34:05 +02:00
|
|
|
y_text: method.to_s.split('_').first.to_sym
|
2012-10-20 22:41:50 +02:00
|
|
|
)
|
|
|
|
end
|
2012-10-20 21:28:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-20 00:30:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|