]> source.dussan.org Git - redmine.git/commitdiff
code clean up app/models/repository.rb
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 20 Sep 2019 13:58:41 +0000 (13:58 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 20 Sep 2019 13:58:41 +0000 (13:58 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@18486 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb

index 93c180a53253b7f79f5fbb7f5c695d5f1df46e56..da13be29e034af0691ed0fa9456067f98d498610 100644 (file)
@@ -421,19 +421,17 @@ class Repository < ActiveRecord::Base
   # Notes:
   # - this hash honnors the users mapping defined for the repository
   def stats_by_author
-    commits = Changeset.where("repository_id = ?", id).select("committer, user_id, count(*) as count").group("committer, user_id")
-
+    commits = Changeset.where("repository_id = ?", id).
+                select("committer, user_id, count(*) as count").group("committer, user_id")
     # TODO: restore ordering ; this line probably never worked
     # commits.to_a.sort! {|x, y| x.last <=> y.last}
-
-    changes = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", id).select("committer, user_id, count(*) as count").group("committer, user_id")
-
+    changes = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", id).
+                select("committer, user_id, count(*) as count").group("committer, user_id")
     user_ids = changesets.map(&:user_id).compact.uniq
     authors_names = User.where(:id => user_ids).inject({}) do |memo, user|
       memo[user.id] = user.to_s
       memo
     end
-
     (commits + changes).inject({}) do |hash, element|
       mapped_name = element.committer
       if username = authors_names[element.user_id.to_i]