mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
Merge pull request #6 from tomgi/lines_for_any_user
Show Lines For Any User
This commit is contained in:
commit
42f7240643
10 changed files with 58 additions and 13 deletions
|
@ -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
|
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
module GitStats
|
module GitStats
|
||||||
VERSION = "1.0.4"
|
VERSION = "1.0.5"
|
||||||
end
|
end
|
||||||
|
|
35
templates/author_details/_author_details.haml
Normal file
35
templates/author_details/_author_details.haml
Normal 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}"
|
1
templates/author_details/changed_lines_by_date.haml
Normal file
1
templates/author_details/changed_lines_by_date.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render_partial('author_details/_author_details', page: :changed_lines_by_date, author: author)
|
1
templates/author_details/commits_by_date.haml
Normal file
1
templates/author_details/commits_by_date.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render_partial('author_details/_author_details', page: :commits_by_date, author: author)
|
1
templates/author_details/deletions_by_date.haml
Normal file
1
templates/author_details/deletions_by_date.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render_partial('author_details/_author_details', page: :deletions_by_date, author: author)
|
1
templates/author_details/insertions_by_date.haml
Normal file
1
templates/author_details/insertions_by_date.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= render_partial('author_details/_author_details', page: :insertions_by_date, author: author)
|
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue