From bb1fccb7b7202ec065fdc39646067054580d278f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 15 May 2007 21:32:36 +0000 Subject: 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 --- app/models/repository.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/models') 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 -- cgit v1.2.3