diff --git a/config/locales/en.yml b/config/locales/en.yml index 50793582c..5d4536e5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,16 +34,16 @@ en: activity: Activity activity_by_date: Activity by date commits_by_date: Commits by date - lines_added_by_author: Lines added by author - lines_deleted_by_author: Lines deleted by author + insertions_by_author: Lines added by author + deletions_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 + insertions_by_author_by_date: Lines added by author by date + deletions_by_author_by_date: Lines deleted by author by date best_authors: Best authors - lines_added: Lines added - lines_deleted: Lines deleted + insertions: Lines added + deletions: Lines deleted first_commit: First_commit last_commit: Last commit author: Author diff --git a/lib/git_stats/git_data/author.rb b/lib/git_stats/git_data/author.rb index aa90cc9fb..ec1f780f9 100644 --- a/lib/git_stats/git_data/author.rb +++ b/lib/git_stats/git_data/author.rb @@ -11,14 +11,6 @@ module GitStats @commits ||= repo.commits.select { |commit| commit.author == self } end - def lines_added - short_stats.map(&:insertions).sum - end - - def lines_deleted - short_stats.map(&:deletions).sum - end - def commits_sum_by_date sum = 0 commits.map { |commit| @@ -28,6 +20,10 @@ module GitStats end [:insertions, :deletions].each do |method| + define_method method do + short_stats.map { |s| s.send(method)} .sum + end + define_method "#{method}_by_date" do sum = 0 commits.map { |commit| diff --git a/lib/git_stats/git_data/repo.rb b/lib/git_stats/git_data/repo.rb index 599a3969c..88c530f26 100644 --- a/lib/git_stats/git_data/repo.rb +++ b/lib/git_stats/git_data/repo.rb @@ -41,7 +41,7 @@ module GitStats Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..limit]] end - [:lines_added, :lines_deleted].each do |method| + [:insertions, :deletions].each do |method| define_method "#{method}_by_author" do |limit = 4| Hash[authors.map { |author| [author, author.send(method)] }.sort_by { |author, lines| -lines }[0..limit]] end diff --git a/lib/git_stats/stats_view/charts/authors_charts.rb b/lib/git_stats/stats_view/charts/authors_charts.rb index e973d6156..a01d698ff 100644 --- a/lib/git_stats/stats_view/charts/authors_charts.rb +++ b/lib/git_stats/stats_view/charts/authors_charts.rb @@ -16,23 +16,15 @@ module GitStats end end - def lines_added_by_author_by_date(limit = 4) - Chart.new do |f| - f.multi_date_chart( - data: @authors.sort_by { |author| -author.lines_added }[0..limit].map { |author| {name: author.email, data: author.insertions_by_date} }, - title: :lines_by_date.t, - y_text: :lines.t - ) - end - end - - def lines_deleted_by_author_by_date(limit = 4) - Chart.new do |f| - f.multi_date_chart( - data: @authors.sort_by { |author| -author.lines_deleted }[0..limit].map { |author| {name: author.email, data: author.deletions_by_date} }, - title: :lines_by_date.t, - y_text: :lines.t - ) + [:insertions, :deletions].each do |method| + define_method "#{method}_by_author_by_date" do |limit = 4| + Chart.new do |f| + f.multi_date_chart( + data: @authors.sort_by { |author| -author.send(method) }[0..limit].map { |author| {name: author.email, data: author.send("#{method}_by_date")} }, + title: :lines_by_date.t, + y_text: :lines.t + ) + end end end diff --git a/lib/git_stats/stats_view/charts/charts.rb b/lib/git_stats/stats_view/charts/charts.rb index f8c01855e..33b2ee642 100644 --- a/lib/git_stats/stats_view/charts/charts.rb +++ b/lib/git_stats/stats_view/charts/charts.rb @@ -3,9 +3,9 @@ module GitStats module Charts class All delegate :files_by_extension, :lines_by_extension, :files_by_date, :lines_by_date, - :commits_count_by_author, :lines_added_by_author, :lines_deleted_by_author, to: :repo_charts + :commits_count_by_author, :insertions_by_author, :deletions_by_author, to: :repo_charts - delegate :commits_sum_by_author_by_date, :lines_added_by_author_by_date, :lines_deleted_by_author_by_date, to: :authors_charts + delegate :commits_sum_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, :activity_by_year, to: :activity_charts diff --git a/lib/git_stats/stats_view/charts/repo_charts.rb b/lib/git_stats/stats_view/charts/repo_charts.rb index c6090a4a8..e39c5ed3c 100644 --- a/lib/git_stats/stats_view/charts/repo_charts.rb +++ b/lib/git_stats/stats_view/charts/repo_charts.rb @@ -46,7 +46,7 @@ module GitStats end end - [:commits_count_by_author, :lines_added_by_author, :lines_deleted_by_author].each do |method| + [:commits_count_by_author, :insertions_by_author, :deletions_by_author].each do |method| define_method method do Chart.new do |f| f.column_hash_chart( diff --git a/spec/git_data/author_spec.rb b/spec/git_data/author_spec.rb index e8de1ae94..b07378245 100644 --- a/spec/git_data/author_spec.rb +++ b/spec/git_data/author_spec.rb @@ -14,11 +14,11 @@ describe GitStats::GitData::Author do end it 'should count lines added from short stat' do - author.lines_added.should == 50 + author.insertions.should == 50 end it 'should count lines deleted from short stat' do - author.lines_deleted.should == 100 + author.deletions.should == 100 end end \ No newline at end of file diff --git a/spec/integration/author_spec.rb b/spec/integration/author_spec.rb index 94036fa55..630adb54d 100644 --- a/spec/integration/author_spec.rb +++ b/spec/integration/author_spec.rb @@ -49,14 +49,14 @@ describe GitStats::GitData::Activity do jd.commits_sum_by_date.map { |d, s| s }.should == [1, 2] end - it 'should count lines_added_by_date' do + it 'should count insertions_by_date' do tg.insertions_by_date.map { |d, s| d }.should == tg_commit_dates tg.insertions_by_date.map { |d, s| s }.should == [4, 9, 14, 15, 20, 1020, 1021, 1021] jd.insertions_by_date.map { |d, s| d }.should == jd_commit_dates jd.insertions_by_date.map { |d, s| s }.should == [3, 103] end - it 'should count lines_deleted_by_date' do + it 'should count deletions_by_date' do tg.deletions_by_date.map { |d, s| d }.should == tg_commit_dates tg.deletions_by_date.map { |d, s| s }.should == [0, 0, 4, 4, 9, 9, 10, 10] jd.deletions_by_date.map { |d, s| d }.should == jd_commit_dates diff --git a/spec/integration/repo_spec.rb b/spec/integration/repo_spec.rb index 6741e08e5..af0ea0354 100644 --- a/spec/integration/repo_spec.rb +++ b/spec/integration/repo_spec.rb @@ -55,13 +55,13 @@ describe GitStats::GitData::Repo do end it 'should count lines_added_by_author' do - repo.lines_added_by_author.keys.should == expected_authors - repo.lines_added_by_author.values.should == [1021, 103] + repo.insertions_by_author.keys.should == expected_authors + repo.insertions_by_author.values.should == [1021, 103] end it 'should count lines_deleted_by_author' do - repo.lines_deleted_by_author.keys.should == expected_authors - repo.lines_deleted_by_author.values.should == [10, 0] + repo.deletions_by_author.keys.should == expected_authors + repo.deletions_by_author.values.should == [10, 0] end end \ No newline at end of file diff --git a/templates/authors.haml b/templates/authors.haml index 4074e49cb..955f928b3 100644 --- a/templates/authors.haml +++ b/templates/authors.haml @@ -5,15 +5,15 @@ %li %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 + %a{:href => '#insertions_by_author', 'data-toogle' => 'tab'}= :insertions_by_author.t %li - %a{:href => '#lines_deleted_by_author', 'data-toogle' => 'tab'}= :lines_deleted_by_author.t + %a{:href => '#deletions_by_author', 'data-toogle' => 'tab'}= :deletions_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 + %a{:href => '#insertions_by_author_by_date', 'data-toogle' => 'tab'}= :insertions_by_author_by_date.t %li - %a{:href => '#lines_deleted_by_author_by_date', 'data-toogle' => 'tab'}= :lines_deleted_by_author_by_date.t + %a{:href => '#deletions_by_author_by_date', 'data-toogle' => 'tab'}= :deletions_by_author_by_date.t .tab-content .tab-pane.active{id: 'best_authors'} @@ -23,8 +23,8 @@ %tr %th= :author.t %th= :commits.t - %th= :lines_added.t - %th= :lines_deleted.t + %th= :insertions.t + %th= :deletions.t %th= :first_commit.t %th= :last_commit.t %th @@ -33,8 +33,8 @@ %tr %th= author.name %td= author.commits.size - %td= author.lines_added - %td= author.lines_deleted + %td= author.insertions + %td= author.deletions %td= author.commits.first.try(:date).try(:to_formatted_s, :long) %td= author.commits.last.try(:date).try(:to_formatted_s, :long) %td @@ -58,24 +58,17 @@ %small %center= "5 #{:best_authors_shown.t}" - .tab-pane{id: 'lines_added_by_author'} + .tab-pane{id: 'insertions_by_author'} .page-header - %h1.pagination-centered= :lines_added_by_author.t - = high_chart("charts.lines_added_by_author", charts.lines_added_by_author) + %h1.pagination-centered= :insertions_by_author.t + = high_chart("charts.insertions_by_author", charts.insertions_by_author) %small %center= "5 #{:best_authors_shown.t}" - .tab-pane{id: 'lines_deleted_by_author'} + .tab-pane{id: 'deletions_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) + %h1.pagination-centered= :deletions_by_author.t + = high_chart("charts.deletions_by_author", charts.insertions_by_author) %small %center= "5 #{:best_authors_shown.t}" @@ -86,9 +79,16 @@ %small %center= "5 #{:best_authors_shown.t}" - .tab-pane{id: 'lines_deleted_by_author_by_date'} + .tab-pane{id: 'insertions_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) + %h1.pagination-centered= :insertions_by_author_by_date.t + = high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date) + %small + %center= "5 #{:best_authors_shown.t}" + + .tab-pane{id: 'deletions_by_author_by_date'} + .page-header + %h1.pagination-centered= :deletions_by_author_by_date.t + = high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date) %small %center= "5 #{:best_authors_shown.t}"