diff options
author | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-08-26 13:58:58 +0000 |
---|---|---|
committer | Jean-Baptiste Barth <jeanbaptiste.barth@gmail.com> | 2014-08-26 13:58:58 +0000 |
commit | 41bf39df36550db5b6ba9ccc167ac02021f69edc (patch) | |
tree | 11c4c2b2ab1c7ba555401302a698fa21266ef376 /app/controllers/repositories_controller.rb | |
parent | e3e14ce3a119f61f22a75c1fdea314e88e0a4d9b (diff) | |
download | redmine-41bf39df36550db5b6ba9ccc167ac02021f69edc.tar.gz redmine-41bf39df36550db5b6ba9ccc167ac02021f69edc.zip |
Move some RepositoriesController logic to Repository#stats_by_author (#13487).
git-svn-id: http://svn.redmine.org/redmine/trunk@13351 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/repositories_controller.rb')
-rw-r--r-- | app/controllers/repositories_controller.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index bdd56f0aa..59afc5529 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -397,16 +397,16 @@ class RepositoriesController < ApplicationController end def graph_commits_per_author(repository) - commits_by_author = Changeset.where("repository_id = ?", repository.id).group(:committer).count - commits_by_author.to_a.sort! {|x, y| x.last <=> y.last} - - changes_by_author = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", repository.id).group(:committer).count - h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o} - - fields = commits_by_author.collect {|r| r.first} - commits_data = commits_by_author.collect {|r| r.last} - changes_data = commits_by_author.collect {|r| h[r.first] || 0} + #data + stats = repository.stats_by_author + fields, commits_data, changes_data = [], [], [] + stats.each do |name, hsh| + fields << name + commits_data << hsh[:commits_count] + changes_data << hsh[:changes_count] + end + #expand to 10 values if needed fields = fields + [""]*(10 - fields.length) if fields.length<10 commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10 changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10 @@ -414,6 +414,7 @@ class RepositoriesController < ApplicationController # Remove email address in usernames fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') } + #prepare graph graph = SVG::Graph::BarHorizontal.new( :height => 30 * commits_data.length, :width => 800, |