mirror of
https://github.com/tomgi/git_stats.git
synced 2025-01-03 11:12:11 +01:00
authors charts
This commit is contained in:
parent
35d77a6392
commit
ab5795a645
8 changed files with 136 additions and 16 deletions
|
@ -34,3 +34,10 @@ en:
|
||||||
activity: Activity
|
activity: Activity
|
||||||
activity_by_date: Activity by date
|
activity_by_date: Activity by date
|
||||||
commits_by_date: Commits by date
|
commits_by_date: Commits by date
|
||||||
|
lines_added_by_author: Lines added by author
|
||||||
|
lines_deleted_by_author: Lines deleted by author
|
||||||
|
best_authors_shown: best authors shown
|
||||||
|
commits_count_by_author: Commits count by author
|
||||||
|
commits_sum_by_author_by_date: Commits sum by author by date
|
||||||
|
lines_added_by_author_by_date: Lines added by author by date
|
||||||
|
lines_deleted_by_author_by_date: Lines deleted by author by date
|
|
@ -19,6 +19,30 @@ module GitStats
|
||||||
short_stats.map(&:deletions).sum
|
short_stats.map(&:deletions).sum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def commits_sum_by_date
|
||||||
|
sum = 0
|
||||||
|
commits.map { |commit|
|
||||||
|
sum += 1
|
||||||
|
[commit.date, sum]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def lines_added_by_date
|
||||||
|
sum = 0
|
||||||
|
commits.map { |commit|
|
||||||
|
sum += commit.short_stat.insertions
|
||||||
|
[commit.date, sum]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def lines_deleted_by_date
|
||||||
|
sum = 0
|
||||||
|
commits.map { |commit|
|
||||||
|
sum += commit.short_stat.deletions
|
||||||
|
[commit.date, sum]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def short_stats
|
def short_stats
|
||||||
commits.map(&:short_stat)
|
commits.map(&:short_stat)
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,12 +37,16 @@ module GitStats
|
||||||
commits.map(&:date).minmax
|
commits.map(&:date).minmax
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def commits_count_by_author
|
||||||
|
Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..5]]
|
||||||
|
end
|
||||||
|
|
||||||
def lines_added_by_author
|
def lines_added_by_author
|
||||||
Hash[authors.map { |author| [author, author.lines_added] }]
|
Hash[authors.map { |author| [author, author.lines_added] }.sort_by { |author, lines| -lines }[0..5]]
|
||||||
end
|
end
|
||||||
|
|
||||||
def lines_deleted_by_author
|
def lines_deleted_by_author
|
||||||
Hash[authors.map { |author| [author, author.lines_deleted] }]
|
Hash[authors.map { |author| [author, author.lines_deleted] }.sort_by { |author, lines| -lines }[0..5]]
|
||||||
end
|
end
|
||||||
|
|
||||||
def files_count_by_date
|
def files_count_by_date
|
||||||
|
|
|
@ -6,17 +6,36 @@ module GitStats
|
||||||
@authors = authors
|
@authors = authors
|
||||||
end
|
end
|
||||||
|
|
||||||
def by_authors_wday
|
def commits_sum_by_author_by_date
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.multiple_column_chart(
|
f.multi_date_chart(
|
||||||
title: :by_authors_wday.t,
|
data: @authors.sort_by { |author| -author.commits.size }[0..5].map { |author| {name: author.email, data: author.commits_sum_by_date} },
|
||||||
y_text: :commits.t,
|
title: :lines_by_date.t,
|
||||||
data_x: Date::ABBR_DAYNAMES,
|
y_text: :lines.t
|
||||||
data_y: @authors.map { |author| {name: author.email, data: author.activity.by_wday.to_key_indexed_array} }
|
|
||||||
)
|
)
|
||||||
f.default_legend
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
def lines_added_by_author_by_date
|
||||||
|
Chart.new do |f|
|
||||||
|
f.multi_date_chart(
|
||||||
|
data: @authors.sort_by { |author| -author.lines_added }[0..5].map { |author| {name: author.email, data: author.lines_added_by_date} },
|
||||||
|
title: :lines_by_date.t,
|
||||||
|
y_text: :lines.t
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def lines_deleted_by_author_by_date
|
||||||
|
Chart.new do |f|
|
||||||
|
f.multi_date_chart(
|
||||||
|
data: @authors.sort_by { |author| -author.lines_deleted }[0..5].map { |author| {name: author.email, data: author.lines_deleted_by_date} },
|
||||||
|
title: :lines_by_date.t,
|
||||||
|
y_text: :lines.t
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,6 +42,18 @@ module GitStats
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def multi_date_chart(params)
|
||||||
|
common_options(params)
|
||||||
|
rangeSelector(selected: 1)
|
||||||
|
params[:data].each do |s|
|
||||||
|
series(
|
||||||
|
name: s[:name],
|
||||||
|
type: "spline",
|
||||||
|
data: s[:data].map { |date, value| [date.to_i * 1000, value] }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def date_column_chart(params)
|
def date_column_chart(params)
|
||||||
date_chart(params)
|
date_chart(params)
|
||||||
data[0][:type] = 'column'
|
data[0][:type] = 'column'
|
||||||
|
|
|
@ -3,9 +3,9 @@ module GitStats
|
||||||
module Charts
|
module Charts
|
||||||
class All
|
class All
|
||||||
delegate :files_by_extension, :lines_by_extension, :files_by_date, :lines_by_date,
|
delegate :files_by_extension, :lines_by_extension, :files_by_date, :lines_by_date,
|
||||||
:lines_added_by_author, :lines_deleted_by_author, to: :repo_charts
|
:commits_count_by_author, :lines_added_by_author, :lines_deleted_by_author, to: :repo_charts
|
||||||
|
|
||||||
delegate :by_authors_wday, to: :authors_charts
|
delegate :commits_sum_by_author_by_date, :lines_added_by_author_by_date, :lines_deleted_by_author_by_date, to: :authors_charts
|
||||||
|
|
||||||
delegate :activity_by_date, :activity_by_hour, :activity_by_wday, :activity_by_month,
|
delegate :activity_by_date, :activity_by_hour, :activity_by_wday, :activity_by_month,
|
||||||
:activity_by_year, to: :activity_charts
|
:activity_by_year, to: :activity_charts
|
||||||
|
|
|
@ -46,13 +46,13 @@ module GitStats
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[:lines_added_by_author, :lines_deleted_by_author].each do |method|
|
[:commits_count_by_author, :lines_added_by_author, :lines_deleted_by_author].each do |method|
|
||||||
define_method method do
|
define_method method do
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.column_hash_chart(
|
f.column_hash_chart(
|
||||||
data: Hash[@repo.send(method).map { |a, l| [a.email, l] }],
|
data: Hash[@repo.send(method).map { |a, l| [a.email, l] }],
|
||||||
title: method.t,
|
title: method.t,
|
||||||
y_text: :lines.t
|
y_text: method.to_s.split('_').first.to_sym
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,57 @@
|
||||||
= high_chart("by_authors_wday", charts.by_authors_wday)
|
.tabbable.tabs-left
|
||||||
= high_chart("lines_added_by_author", charts.lines_added_by_author)
|
%ul.nav.nav-tabs
|
||||||
= high_chart("lines_deleted_by_author", charts.lines_deleted_by_author)
|
%li.active
|
||||||
|
%a{:href => '#commits_count_by_author', 'data-toogle' => 'tab'}= :commits_count_by_author.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#lines_added_by_author', 'data-toogle' => 'tab'}= :lines_added_by_author.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#lines_deleted_by_author', 'data-toogle' => 'tab'}= :lines_deleted_by_author.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#commits_sum_by_author_by_date', 'data-toogle' => 'tab'}= :commits_sum_by_author_by_date.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#lines_added_by_author_by_date', 'data-toogle' => 'tab'}= :lines_added_by_author_by_date.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#lines_deleted_by_author_by_date', 'data-toogle' => 'tab'}= :lines_deleted_by_author_by_date.t
|
||||||
|
|
||||||
|
.tab-content
|
||||||
|
.tab-pane.active{id: 'commits_count_by_author'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :commits_count_by_author.t
|
||||||
|
= high_chart("charts.commits_count_by_author", charts.commits_count_by_author)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
||||||
|
.tab-pane{id: 'lines_added_by_author'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :lines_added_by_author.t
|
||||||
|
= high_chart("charts.lines_added_by_author", charts.lines_added_by_author)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
||||||
|
.tab-pane{id: 'lines_deleted_by_author'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :lines_deleted_by_author.t
|
||||||
|
= high_chart("charts.lines_deleted_by_author", charts.lines_deleted_by_author)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
||||||
|
.tab-pane{id: 'lines_added_by_author_by_date'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :lines_added_by_author_by_date.t
|
||||||
|
= high_stock("charts.lines_added_by_author_by_date", charts.lines_added_by_author_by_date)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
||||||
|
.tab-pane{id: 'commits_sum_by_author_by_date'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :commits_sum_by_author_by_date.t
|
||||||
|
= high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
||||||
|
.tab-pane{id: 'lines_deleted_by_author_by_date'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :lines_deleted_by_author_by_date.t
|
||||||
|
= high_stock("charts.lines_deleted_by_author_by_date", charts.lines_deleted_by_author_by_date)
|
||||||
|
%small
|
||||||
|
%center= "5 #{:best_authors_shown.t}"
|
||||||
|
|
Loading…
Reference in a new issue