Class: GitStats::StatsView::Charts::AuthorsCharts

Inherits:
Object
  • Object
show all
Defined in:
lib/git_stats/stats_view/charts/authors_charts.rb

Constant Summary collapse

AUTHORS_ON_CHART_LIMIT =
4

Instance Method Summary collapse

Constructor Details

#initialize(authors) ⇒ AuthorsCharts

Returns a new instance of AuthorsCharts.


8
9
10
# File 'lib/git_stats/stats_view/charts/authors_charts.rb', line 8

def initialize(authors)
  @authors = authors
end

Instance Method Details

#commits_sum_by_author_by_date(authors = nil) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/git_stats/stats_view/charts/authors_charts.rb', line 12

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..AUTHORS_ON_CHART_LIMIT]).map { |author| {name: author.name, data: author.commits_sum_by_date} },
        title: :lines_by_date.t,
        y_text: :lines.t
    )
  end
end