changed lines = insertions + deletions

This commit is contained in:
Tomasz Gieniusz 2012-10-21 23:53:31 +02:00
parent 7af4c6facf
commit b1713e3bff
8 changed files with 37 additions and 8 deletions

View File

@ -36,11 +36,13 @@ en:
commits_by_date: Commits by date commits_by_date: Commits by date
insertions_by_author: Lines added by author insertions_by_author: Lines added by author
deletions_by_author: Lines deleted by author deletions_by_author: Lines deleted by author
changed_lines_by_author: Changed lines by author
best_authors_shown: best authors shown best_authors_shown: best authors shown
commits_count_by_author: Commits count by author commits_count_by_author: Commits count by author
commits_sum_by_author_by_date: Commits sum by author by date commits_sum_by_author_by_date: Commits sum by author by date
insertions_by_author_by_date: Lines added by author by date insertions_by_author_by_date: Lines added by author by date
deletions_by_author_by_date: Lines deleted by author by date deletions_by_author_by_date: Lines deleted by author by date
changed_lines_by_author_by_date: Changed lines by author by date
best_authors: Best authors best_authors: Best authors
insertions: Lines added insertions: Lines added
deletions: Lines deleted deletions: Lines deleted

View File

@ -11,6 +11,10 @@ module GitStats
@commits ||= repo.commits.select { |commit| commit.author == self } @commits ||= repo.commits.select { |commit| commit.author == self }
end end
def changed_lines
insertions + deletions
end
def insertions def insertions
short_stats.map(&:insertions).sum short_stats.map(&:insertions).sum
end end
@ -27,7 +31,7 @@ module GitStats
} }
end end
[:insertions, :deletions].each do |method| [:insertions, :deletions, :changed_lines].each do |method|
define_method "#{method}_by_date" do define_method "#{method}_by_date" do
sum = 0 sum = 0
commits.map { |commit| commits.map { |commit|

View File

@ -41,7 +41,7 @@ module GitStats
Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..limit]] Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..limit]]
end end
[:insertions, :deletions].each do |method| [:insertions, :deletions, :changed_lines].each do |method|
define_method "#{method}_by_author" do |limit = 4| define_method "#{method}_by_author" do |limit = 4|
Hash[authors.map { |author| [author, author.send(method)] }.sort_by { |author, lines| -lines }[0..limit]] Hash[authors.map { |author| [author, author.send(method)] }.sort_by { |author, lines| -lines }[0..limit]]
end end

View File

@ -8,6 +8,10 @@ module GitStats
calculate_stat calculate_stat
end end
def changed_lines
insertions + deletions
end
def to_s def to_s
"#{self.class} #@commit" "#{self.class} #@commit"
end end

View File

@ -16,7 +16,7 @@ module GitStats
end end
end end
[:insertions, :deletions].each do |method| [:insertions, :deletions, :changed_lines].each do |method|
define_method "#{method}_by_author_by_date" do |limit = 4| define_method "#{method}_by_author_by_date" do |limit = 4|
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( f.multi_date_chart(

View File

@ -2,10 +2,11 @@ module GitStats
module StatsView module StatsView
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, :commits_count_by_author,
:commits_count_by_author, :insertions_by_author, :deletions_by_author, to: :repo_charts :changed_lines_by_author, :insertions_by_author, :deletions_by_author, to: :repo_charts
delegate :commits_sum_by_author_by_date, :insertions_by_author_by_date, :deletions_by_author_by_date, to: :authors_charts delegate :commits_sum_by_author_by_date, :changed_lines_by_author_by_date,
:insertions_by_author_by_date, :deletions_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

View File

@ -46,7 +46,7 @@ module GitStats
end end
end end
[:commits_count_by_author, :insertions_by_author, :deletions_by_author].each do |method| [:commits_count_by_author, :insertions_by_author, :deletions_by_author, :changed_lines_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(

View File

@ -4,12 +4,16 @@
%a{:href => '#best_authors', 'data-toogle' => 'tab'}= :best_authors.t %a{:href => '#best_authors', 'data-toogle' => 'tab'}= :best_authors.t
%li %li
%a{:href => '#commits_count_by_author', 'data-toogle' => 'tab'}= :commits_count_by_author.t %a{:href => '#commits_count_by_author', 'data-toogle' => 'tab'}= :commits_count_by_author.t
%li
%a{:href => '#changed_lines_by_author', 'data-toogle' => 'tab'}= :changed_lines_by_author.t
%li %li
%a{:href => '#insertions_by_author', 'data-toogle' => 'tab'}= :insertions_by_author.t %a{:href => '#insertions_by_author', 'data-toogle' => 'tab'}= :insertions_by_author.t
%li %li
%a{:href => '#deletions_by_author', 'data-toogle' => 'tab'}= :deletions_by_author.t %a{:href => '#deletions_by_author', 'data-toogle' => 'tab'}= :deletions_by_author.t
%li %li
%a{:href => '#commits_sum_by_author_by_date', 'data-toogle' => 'tab'}= :commits_sum_by_author_by_date.t %a{:href => '#commits_sum_by_author_by_date', 'data-toogle' => 'tab'}= :commits_sum_by_author_by_date.t
%li
%a{:href => '#changed_lines_by_author_by_date', 'data-toogle' => 'tab'}= :changed_lines_by_author_by_date.t
%li %li
%a{:href => '#insertions_by_author_by_date', 'data-toogle' => 'tab'}= :insertions_by_author_by_date.t %a{:href => '#insertions_by_author_by_date', 'data-toogle' => 'tab'}= :insertions_by_author_by_date.t
%li %li
@ -58,6 +62,13 @@
%small %small
%center= "5 #{:best_authors_shown.t}" %center= "5 #{:best_authors_shown.t}"
.tab-pane{id: 'changed_lines_by_author'}
.page-header
%h1.pagination-centered= :changed_lines_by_author.t
= high_chart("charts.changed_lines_by_author", charts.changed_lines_by_author)
%small
%center= "5 #{:best_authors_shown.t}"
.tab-pane{id: 'insertions_by_author'} .tab-pane{id: 'insertions_by_author'}
.page-header .page-header
%h1.pagination-centered= :insertions_by_author.t %h1.pagination-centered= :insertions_by_author.t
@ -68,7 +79,7 @@
.tab-pane{id: 'deletions_by_author'} .tab-pane{id: 'deletions_by_author'}
.page-header .page-header
%h1.pagination-centered= :deletions_by_author.t %h1.pagination-centered= :deletions_by_author.t
= high_chart("charts.deletions_by_author", charts.insertions_by_author) = high_chart("charts.deletions_by_author", charts.deletions_by_author)
%small %small
%center= "5 #{:best_authors_shown.t}" %center= "5 #{:best_authors_shown.t}"
@ -86,6 +97,13 @@
%small %small
%center= "5 #{:best_authors_shown.t}" %center= "5 #{:best_authors_shown.t}"
.tab-pane{id: 'changed_lines_by_author_by_date'}
.page-header
%h1.pagination-centered= :changed_lines_by_author_by_date.t
= high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date)
%small
%center= "5 #{:best_authors_shown.t}"
.tab-pane{id: 'deletions_by_author_by_date'} .tab-pane{id: 'deletions_by_author_by_date'}
.page-header .page-header
%h1.pagination-centered= :deletions_by_author_by_date.t %h1.pagination-centered= :deletions_by_author_by_date.t