diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-05-15 21:32:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-05-15 21:32:36 +0000 |
commit | bb1fccb7b7202ec065fdc39646067054580d278f (patch) | |
tree | c82b1c393e4e39a9a3bda4ab87b358ffe7db11e8 /app | |
parent | 777c9acae8d6ea59ba54f915edff85b8ebb26546 (diff) | |
download | redmine-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')
-rw-r--r-- | app/controllers/repositories_controller.rb | 9 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | app/views/repositories/revision.rhtml | 7 |
3 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index fdfe936f7..4252e58be 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -49,7 +49,7 @@ class RepositoriesController < ApplicationController show_error and return unless @entry end @repository.changesets_with_path @path do - @changeset_count = @repository.changesets.count + @changeset_count = @repository.changesets.count(:select => "DISTINCT #{Changeset.table_name}.id") @changeset_pages = Paginator.new self, @changeset_count, 25, params['page'] @@ -71,6 +71,13 @@ class RepositoriesController < ApplicationController def revision @changeset = @repository.changesets.find_by_revision(@rev) show_error and return unless @changeset + @changes_count = @changeset.changes.size + @changes_pages = Paginator.new self, @changes_count, 150, params['page'] + @changes = @changeset.changes.find(:all, + :limit => @changes_pages.items_per_page, + :offset => @changes_pages.current.offset) + + render :action => "revision", :layout => false if request.xhr? end def diff 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 diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index 8919e45a2..5cf5c2e41 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -28,7 +28,7 @@ <p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p> <table class="list"> <tbody> -<% @changeset.changes.each do |change| %> +<% @changes.each do |change| %> <tr class="<%= cycle 'odd', 'even' %>"> <td><div class="square action_<%= change.action %>"></div> <%= change.path %></td> <td align="right"> @@ -40,8 +40,9 @@ <% end %> </tbody> </table> -<p><%= lwr(:label_modification, @changeset.changes.length) %></p> +<p><%= pagination_links_full @changes_pages, :rev => @changeset.revision %> +[ <%= @changes_pages.current.first_item %> - <%= @changes_pages.current.last_item %> / <%= @changes_count %> ]</p> <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> -<% end %>
\ No newline at end of file +<% end %> |