#6 Show Lines For Any User

This commit is contained in:
Tomasz Gieniusz 2013-02-21 11:15:58 +01:00
parent 18b3f8d3bc
commit 926617e283
9 changed files with 57 additions and 12 deletions

View File

@ -53,4 +53,8 @@ en:
close: Close close: Close
binary: Binary binary: Binary
text: Text text: Text
general: General general: General
details: Details
insertions_by_date: Lines added by date
deletions_by_date: Lines deleted by date
changed_lines_by_date: Changed lines by date

View File

@ -7,10 +7,10 @@ module GitStats
@authors = authors @authors = authors
end end
def commits_sum_by_author_by_date(limit = 4) def commits_sum_by_author_by_date(limit = 4, authors = nil)
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( f.multi_date_chart(
data: @authors.sort_by { |author| -author.commits.size }[0..limit].map { |author| {name: author.name, data: author.commits_sum_by_date} }, data: (authors || @authors.sort_by { |author| -author.commits.size }[0..limit]).map { |author| {name: author.name, data: author.commits_sum_by_date} },
title: :lines_by_date.t, title: :lines_by_date.t,
y_text: :lines.t y_text: :lines.t
) )
@ -18,10 +18,10 @@ module GitStats
end end
[:insertions, :deletions, :changed_lines].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, authors = nil|
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( f.multi_date_chart(
data: @authors.sort_by { |author| -author.send(method) }[0..limit].map { |author| {name: author.name, data: author.send("#{method}_by_date")} }, data: (authors || @authors.sort_by { |author| -author.send(method) }[0..limit]).map { |author| {name: author.name, data: author.send("#{method}_by_date")} },
title: :lines_by_date.t, title: :lines_by_date.t,
y_text: :lines.t y_text: :lines.t
) )

View File

@ -11,20 +11,20 @@ module GitStats
prepare_static_content prepare_static_content
prepare_assets prepare_assets
all_templates.each do |template| all_templates.reject {|t| t =~ /author_details/}.each do |template|
output = Template.new(template, @layout).render(@view_data, author: @view_data.repo, links: links) output = Template.new(template, @layout).render(@view_data, author: @view_data.repo, links: links)
write(output, "#@out_path/#{template}.html") write(output, "#@out_path/#{template}.html")
end end
render_authors_activity render_authors
end end
def render_authors_activity def render_authors
done = [] done = []
@view_data.repo.authors.sort_by { |a| -a.commits.size }.each do |author| @view_data.repo.authors.sort_by { |a| -a.commits.size }.each do |author|
next if done.include? author.dirname next if done.include? author.dirname
done << author.dirname done << author.dirname
all_templates('activity/').each do |template| (all_templates('activity/') + all_templates('author_details')).each do |template|
output = Template.new(template, @layout).render(@view_data, output = Template.new(template, @layout).render(@view_data,
author: author, author: author,
links: links, links: links,
@ -35,11 +35,11 @@ module GitStats
end end
def all_templates(root = '') def all_templates(root = '')
Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map { (Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
|f| Pathname.new(f) |f| Pathname.new(f)
}.map { |f| }.map { |f|
f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('') f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('')
}.map(&:to_s) - %w(layout) }.map(&:to_s) - %w(layout))
end end
private private

View File

@ -0,0 +1,35 @@
.tabbable.tabs-left
%ul.nav.nav-tabs
%li{class: page == :commits_by_date ? "active" : ""}
%a{href: 'commits_by_date.html'}= :commits_by_date.t
%li{class: page == :changed_lines_by_date ? "active" : ""}
%a{href: 'changed_lines_by_date.html'}= :changed_lines_by_date.t
%li{class: page == :insertions_by_date ? "active" : ""}
%a{href: 'insertions_by_date.html'}= :insertions_by_date.t
%li{class: page == :deletions_by_date ? "active" : ""}
%a{href: 'deletions_by_date.html'}= :deletions_by_date.t
.tab-content
.tab-pane.active
.page-header
%h1.pagination-centered= page.t
-if page == :commits_by_date
= high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date(4, [author]))
%small
%center= "5 #{:best_authors_shown.t}"
-elsif page == :changed_lines_by_date
= high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date(4, [author]))
%small
%center= "5 #{:best_authors_shown.t}"
-elsif page == :insertions_by_date
= high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date(4, [author]))
%small
%center= "5 #{:best_authors_shown.t}"
-elsif page == :deletions_by_date
= high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date(4, [author]))
%small
%center= "5 #{:best_authors_shown.t}"

View File

@ -0,0 +1 @@
= render_partial('author_details/_author_details', page: :changed_lines_by_date, author: author)

View File

@ -0,0 +1 @@
= render_partial('author_details/_author_details', page: :commits_by_date, author: author)

View File

@ -0,0 +1 @@
= render_partial('author_details/_author_details', page: :deletions_by_date, author: author)

View File

@ -0,0 +1 @@
= render_partial('author_details/_author_details', page: :insertions_by_date, author: author)

View File

@ -38,7 +38,9 @@
%td= I18n.localize(author.commits.first.try(:date), format: :long) rescue "" %td= I18n.localize(author.commits.first.try(:date), format: :long) rescue ""
%td= I18n.localize(author.commits.last.try(:date), format: :long) rescue "" %td= I18n.localize(author.commits.last.try(:date), format: :long) rescue ""
%td %td
%a.btn{:href => "#{author.dirname}/activity/by_date.html"}= :show_more.t %a.btn{:href => "#{author.dirname}/activity/by_date.html"}= :activity.t
%td
%a.btn{:href => "#{author.dirname}/author_details/commits_by_date.html"}= :details.t
-elsif page == :commits_count_by_author -elsif page == :commits_count_by_author
= high_chart("charts.commits_count_by_author", charts.commits_count_by_author(4)) = high_chart("charts.commits_count_by_author", charts.commits_count_by_author(4))