Project

General

Profile

Feature #2065 » redmine-merge-homonyms.patch

Patch merging homonyms for app app/controllers/repositories_controller.rb - Guillaume Ayoub, 2009-11-11 15:39

View differences:

repositories_controller.rb 2009-11-11 05:50:06.000000000 +0100
268 268

  
269 269
  def graph_commits_per_author(repository)
270 270
    commits_by_author = repository.changesets.count(:all, :group => :committer)
271
    commits_by_author.sort! {|x, y| x.last <=> y.last}
272

  
273 271
    changes_by_author = repository.changes.count(:all, :group => :committer)
274 272
    h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
275 273
    
276
    fields = commits_by_author.collect {|r| r.first}
277
    commits_data = commits_by_author.collect {|r| r.last}
278
    changes_data = commits_by_author.collect {|r| h[r.first] || 0}
274
    # Aggregate data
275
    commits_data_aggregate = Hash.new(0)
276
    changes_data_aggregate = Hash.new(0)
277

  
278
    for commit in commits_by_author
279
      name = commit.first.gsub(%r{<.+@.+>}, '')
280
      commits_data_aggregate[name] += commit.last
281
      changes_data_aggregate[name] += h[commit.first] || 0
282
    end
283

  
284
    # Sort fields
285
    commits_data_array = commits_data_aggregate.sort {|x, y| x.last <=> y.last}
286

  
287
    fields = commits_data_array.collect {|r| r.first}
288
    commits_data = commits_data_array.collect {|r| r.last}
289
    changes_data = fields.collect {|f| changes_data_aggregate[f]}
279 290
    
280 291
    fields = fields + [""]*(10 - fields.length) if fields.length<10
281 292
    commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
282 293
    changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
283 294
    
284
    # Remove email adress in usernames
285
    fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
286
    
287 295
    graph = SVG::Graph::BarHorizontal.new(
288 296
      :height => 400,
289 297
      :width => 800,
(1-1/2)