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
This commit is contained in:
Jean-Philippe Lang
2007-05-15 21:32:36 +00:00
parent 777c9acae8
commit bb1fccb7b7
5 changed files with 47 additions and 10 deletions
+3 -1
View File
@@ -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