mirror of https://github.com/tomgi/git_stats.git
replaced unused authors per chart parameter with a const
This commit is contained in:
parent
d140754c8d
commit
94fb79308d
|
@ -5,7 +5,6 @@ module GitStats
|
|||
delegate :render_all, to: :@view
|
||||
|
||||
def initialize(options)
|
||||
|
||||
validate_repo_path(options[:path])
|
||||
|
||||
@repo = GitData::Repo.new(options)
|
||||
|
|
|
@ -3,14 +3,16 @@ module GitStats
|
|||
module StatsView
|
||||
module Charts
|
||||
class AuthorsCharts
|
||||
AUTHORS_ON_CHART_LIMIT = 4
|
||||
|
||||
def initialize(authors)
|
||||
@authors = authors
|
||||
end
|
||||
|
||||
def commits_sum_by_author_by_date(limit = 4, authors = nil)
|
||||
def commits_sum_by_author_by_date(authors = nil)
|
||||
Chart.new do |f|
|
||||
f.multi_date_chart(
|
||||
data: (authors || @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..AUTHORS_ON_CHART_LIMIT]).map { |author| {name: author.name, data: author.commits_sum_by_date} },
|
||||
title: :lines_by_date.t,
|
||||
y_text: :lines.t
|
||||
)
|
||||
|
@ -18,10 +20,10 @@ module GitStats
|
|||
end
|
||||
|
||||
[:insertions, :deletions, :changed_lines].each do |method|
|
||||
define_method "#{method}_by_author_by_date" do |limit = 4, authors = nil|
|
||||
define_method "#{method}_by_author_by_date" do |authors = nil|
|
||||
Chart.new do |f|
|
||||
f.multi_date_chart(
|
||||
data: (authors || @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..AUTHORS_ON_CHART_LIMIT]).map { |author| {name: author.name, data: author.send("#{method}_by_date")} },
|
||||
title: :lines_by_date.t,
|
||||
y_text: :lines.t
|
||||
)
|
||||
|
|
|
@ -15,21 +15,21 @@
|
|||
%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]))
|
||||
= high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date([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]))
|
||||
= high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date([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]))
|
||||
= high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date([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]))
|
||||
= high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date([author]))
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
|
@ -43,26 +43,26 @@
|
|||
%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))
|
||||
= high_chart("charts.commits_count_by_author", charts.commits_count_by_author)
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
||||
|
||||
-elsif page == :commits_sum_by_author_by_date
|
||||
= high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date(4))
|
||||
= high_stock("charts.commits_sum_by_author_by_date", charts.commits_sum_by_author_by_date)
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
||||
|
||||
-elsif page == :changed_lines_by_author_by_date
|
||||
= high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date(4))
|
||||
= high_stock("charts.changed_lines_by_author_by_date", charts.changed_lines_by_author_by_date)
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
||||
|
||||
-elsif page == :insertions_by_author_by_date
|
||||
= high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date(4))
|
||||
= high_stock("charts.insertions_by_author_by_date", charts.insertions_by_author_by_date)
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
||||
|
||||
-elsif page == :deletions_by_author_by_date
|
||||
= high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date(4))
|
||||
= high_stock("charts.deletions_by_author_by_date", charts.deletions_by_author_by_date)
|
||||
%small
|
||||
%center= "5 #{:best_authors_shown.t}"
|
||||
|
|
Loading…
Reference in New Issue