summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-15 21:32:36 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-15 21:32:36 +0000
commitbb1fccb7b7202ec065fdc39646067054580d278f (patch)
treec82b1c393e4e39a9a3bda4ab87b358ffe7db11e8 /app/models
parent777c9acae8d6ea59ba54f915edff85b8ebb26546 (diff)
downloadredmine-bb1fccb7b7202ec065fdc39646067054580d278f.tar.gz
redmine-bb1fccb7b7202ec065fdc39646067054580d278f.zip
Fixed: performance issue on RepositoriesController#revisions when a changeset has a great number of changes (eg. 100,000).
Also added pagination for changes on changeset details view. git-svn-id: http://redmine.rubyforge.org/svn/trunk@535 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 02dfda6b7..692c446d6 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -40,7 +40,9 @@ class Repository < ActiveRecord::Base
path = "/#{path}%"
path = url.gsub(/^#{root_url}/, '') + path if root_url && root_url != url
path.squeeze!("/")
- Changeset.with_scope(:find => { :include => :changes, :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
+ # Custom select and joins is done to allow conditions on changes table without loading associated Change objects
+ # Required for changesets with a great number of changes (eg. 100,000)
+ Changeset.with_scope(:find => { :select => "DISTINCT #{Changeset.table_name}.*", :joins => "LEFT OUTER JOIN #{Change.table_name} ON #{Change.table_name}.changeset_id = #{Changeset.table_name}.id", :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
yield
end
end