Commit 3d393a57 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Memorize commit authors to speed up changesets loading.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3472 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 93bcc680
...@@ -136,6 +136,7 @@ class Repository < ActiveRecord::Base ...@@ -136,6 +136,7 @@ class Repository < ActiveRecord::Base
end end
end end
@committers = nil @committers = nil
@found_committer_users = nil
true true
else else
false false
...@@ -146,16 +147,22 @@ class Repository < ActiveRecord::Base ...@@ -146,16 +147,22 @@ class Repository < ActiveRecord::Base
# It will return nil if the committer is not yet mapped and if no User # It will return nil if the committer is not yet mapped and if no User
# with the same username or email was found # with the same username or email was found
def find_committer_user(committer) def find_committer_user(committer)
if committer unless committer.blank?
@found_committer_users ||= {}
return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
user = nil
c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user) c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
if c && c.user if c && c.user
c.user user = c.user
elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/ elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
username, email = $1.strip, $3 username, email = $1.strip, $3
u = User.find_by_login(username) u = User.find_by_login(username)
u ||= User.find_by_mail(email) unless email.blank? u ||= User.find_by_mail(email) unless email.blank?
u user = u
end end
@found_committer_users[committer] = user
user
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment