mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-20 07:21:12 +00:00
code clean up app/models/repository.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@18486 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7fb47e4b5e
commit
4074ca0771
@ -421,19 +421,17 @@ class Repository < ActiveRecord::Base
|
|||||||
# Notes:
|
# Notes:
|
||||||
# - this hash honnors the users mapping defined for the repository
|
# - this hash honnors the users mapping defined for the repository
|
||||||
def stats_by_author
|
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
|
# TODO: restore ordering ; this line probably never worked
|
||||||
# commits.to_a.sort! {|x, y| x.last <=> y.last}
|
# commits.to_a.sort! {|x, y| x.last <=> y.last}
|
||||||
|
changes = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", id).
|
||||||
changes = Change.joins(:changeset).where("#{Changeset.table_name}.repository_id = ?", id).select("committer, user_id, count(*) as count").group("committer, user_id")
|
select("committer, user_id, count(*) as count").group("committer, user_id")
|
||||||
|
|
||||||
user_ids = changesets.map(&:user_id).compact.uniq
|
user_ids = changesets.map(&:user_id).compact.uniq
|
||||||
authors_names = User.where(:id => user_ids).inject({}) do |memo, user|
|
authors_names = User.where(:id => user_ids).inject({}) do |memo, user|
|
||||||
memo[user.id] = user.to_s
|
memo[user.id] = user.to_s
|
||||||
memo
|
memo
|
||||||
end
|
end
|
||||||
|
|
||||||
(commits + changes).inject({}) do |hash, element|
|
(commits + changes).inject({}) do |hash, element|
|
||||||
mapped_name = element.committer
|
mapped_name = element.committer
|
||||||
if username = authors_names[element.user_id.to_i]
|
if username = authors_names[element.user_id.to_i]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user