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
|
@ -54,3 +54,7 @@ en:
|
|||
binary: Binary
|
||||
text: Text
|
||||
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
|
||||
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|
|
||||
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,
|
||||
y_text: :lines.t
|
||||
)
|
||||
|
@ -18,10 +18,10 @@ module GitStats
|
|||
end
|
||||
|
||||
[: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|
|
||||
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,
|
||||
y_text: :lines.t
|
||||
)
|
||||
|
|
|
@ -11,20 +11,20 @@ module GitStats
|
|||
prepare_static_content
|
||||
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)
|
||||
write(output, "#@out_path/#{template}.html")
|
||||
end
|
||||
|
||||
render_authors_activity
|
||||
render_authors
|
||||
end
|
||||
|
||||
def render_authors_activity
|
||||
def render_authors
|
||||
done = []
|
||||
@view_data.repo.authors.sort_by { |a| -a.commits.size }.each do |author|
|
||||
next if done.include? 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,
|
||||
author: author,
|
||||
links: links,
|
||||
|
@ -35,11 +35,11 @@ module GitStats
|
|||
end
|
||||
|
||||
def all_templates(root = '')
|
||||
Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
|
||||
(Dir["../../../../templates/#{root}**/[^_]*.haml".absolute_path].map {
|
||||
|f| Pathname.new(f)
|
||||
}.map { |f|
|
||||
f.relative_path_from(Pathname.new('../../../../templates'.absolute_path)).sub_ext('')
|
||||
}.map(&:to_s) - %w(layout)
|
||||
}.map(&:to_s) - %w(layout))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module GitStats
|
||||
VERSION = "1.0.4"
|
||||
VERSION = "1.0.5"
|
||||
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.last.try(:date), format: :long) rescue ""
|
||||
%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
|
||||
= high_chart("charts.commits_count_by_author", charts.commits_count_by_author(4))
|
||||
|
|
Loading…
Reference in a new issue