summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-02-21 14:42:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-02-21 14:42:45 +0000
commit3d393a5711f6e934aa2275d06ef31bab6e902e07 (patch)
treeb38b4a6999c0ebeed7b9bf886325f798f7fc0eaf
parent93bcc68017833096ad8080f1a2b67b87c6fc6466 (diff)
downloadredmine-3d393a5711f6e934aa2275d06ef31bab6e902e07.tar.gz
redmine-3d393a5711f6e934aa2275d06ef31bab6e902e07.zip
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
-rw-r--r--app/models/repository.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index da1168dfd..dee705c97 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -136,6 +136,7 @@ class Repository < ActiveRecord::Base
end
end
@committers = nil
+ @found_committer_users = nil
true
else
false
@@ -146,16 +147,22 @@ class Repository < ActiveRecord::Base
# It will return nil if the committer is not yet mapped and if no User
# with the same username or email was found
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)
if c && c.user
- c.user
+ user = c.user
elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
username, email = $1.strip, $3
u = User.find_by_login(username)
u ||= User.find_by_mail(email) unless email.blank?
- u
+ user = u
end
+ @found_committer_users[committer] = user
+ user
end
end