Replaces find(:all) calls.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10914 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-02 19:09:42 +00:00
parent 1951c6a3fd
commit 5b21efd4a4
10 changed files with 29 additions and 26 deletions

View File

@ -23,7 +23,7 @@ class CustomFieldsController < ApplicationController
before_filter :find_custom_field, :only => [:edit, :update, :destroy] before_filter :find_custom_field, :only => [:edit, :update, :destroy]
def index def index
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
@tab = params[:tab] || 'IssueCustomField' @tab = params[:tab] || 'IssueCustomField'
end end

View File

@ -43,7 +43,7 @@ class DocumentsController < ApplicationController
end end
def show def show
@attachments = @document.attachments.find(:all, :order => "created_on DESC") @attachments = @document.attachments.all
end end
def new def new

View File

@ -40,10 +40,12 @@ class MessagesController < ApplicationController
@reply_count = @topic.children.count @reply_count = @topic.children.count
@reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page @reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}], @replies = @topic.children.
:order => "#{Message.table_name}.created_on ASC", includes(:author, :attachments, {:board => :project}).
:limit => @reply_pages.items_per_page, reorder("#{Message.table_name}.created_on ASC").
:offset => @reply_pages.current.offset) limit(@reply_pages.items_per_page).
offset(@reply_pages.current.offset).
all
@reply = Message.new(:subject => "RE: #{@message.subject}") @reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => false if request.xhr? render :action => "show", :layout => false if request.xhr?

View File

@ -57,11 +57,10 @@ class ProjectsController < ApplicationController
format.api { format.api {
@offset, @limit = api_offset_and_limit @offset, @limit = api_offset_and_limit
@project_count = Project.visible.count @project_count = Project.visible.count
@projects = Project.visible.all(:offset => @offset, :limit => @limit, :order => 'lft') @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
} }
format.atom { format.atom {
projects = Project.visible.find(:all, :order => 'created_on DESC', projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
:limit => Setting.feeds_limit.to_i)
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
} }
end end
@ -145,7 +144,7 @@ class ProjectsController < ApplicationController
@users_by_role = @project.users_by_role @users_by_role = @project.users_by_role
@subprojects = @project.children.visible.all @subprojects = @project.children.visible.all
@news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all
@trackers = @project.rolled_up_trackers @trackers = @project.rolled_up_trackers
cond = @project.project_condition(Setting.display_subprojects_issues?) cond = @project.project_condition(Setting.display_subprojects_issues?)

View File

@ -90,6 +90,6 @@ class ReportsController < ApplicationController
private private
def find_issue_statuses def find_issue_statuses
@statuses = IssueStatus.find(:all, :order => 'position') @statuses = IssueStatus.sorted.all
end end
end end

View File

@ -141,10 +141,11 @@ class RepositoriesController < ApplicationController
@changeset_pages = Paginator.new self, @changeset_count, @changeset_pages = Paginator.new self, @changeset_count,
per_page_option, per_page_option,
params['page'] params['page']
@changesets = @repository.changesets.find(:all, @changesets = @repository.changesets.
:limit => @changeset_pages.items_per_page, limit(@changeset_pages.items_per_page).
:offset => @changeset_pages.current.offset, offset(@changeset_pages.current.offset).
:include => [:user, :repository, :parents]) includes(:user, :repository, :parents).
all
respond_to do |format| respond_to do |format|
format.html { render :layout => false if request.xhr? } format.html { render :layout => false if request.xhr? }

View File

@ -37,7 +37,7 @@ class TrackersController < ApplicationController
def new def new
@tracker ||= Tracker.new(params[:tracker]) @tracker ||= Tracker.new(params[:tracker])
@trackers = Tracker.find :all, :order => 'position' @trackers = Tracker.find :all, :order => 'position'
@projects = Project.find(:all) @projects = Project.all
end end
def create def create
@ -57,7 +57,7 @@ class TrackersController < ApplicationController
def edit def edit
@tracker ||= Tracker.find(params[:id]) @tracker ||= Tracker.find(params[:id])
@projects = Project.find(:all) @projects = Project.all
end end
def update def update

View File

@ -83,7 +83,7 @@ class UsersController < ApplicationController
def new def new
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.all
end end
def create def create
@ -112,7 +112,7 @@ class UsersController < ApplicationController
format.api { render :action => 'show', :status => :created, :location => user_url(@user) } format.api { render :action => 'show', :status => :created, :location => user_url(@user) }
end end
else else
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.all
# Clear password input # Clear password input
@user.password = @user.password_confirmation = nil @user.password = @user.password_confirmation = nil
@ -124,7 +124,7 @@ class UsersController < ApplicationController
end end
def edit def edit
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.all
@membership ||= Member.new @membership ||= Member.new
end end
@ -159,7 +159,7 @@ class UsersController < ApplicationController
format.api { render_api_ok } format.api { render_api_ok }
end end
else else
@auth_sources = AuthSource.find(:all) @auth_sources = AuthSource.all
@membership ||= Member.new @membership ||= Member.new
# Clear password input # Clear password input
@user.password = @user.password_confirmation = nil @user.password = @user.password_confirmation = nil

View File

@ -31,7 +31,7 @@ class VersionsController < ApplicationController
def index def index
respond_to do |format| respond_to do |format|
format.html { format.html {
@trackers = @project.trackers.find(:all, :order => 'position') @trackers = @project.trackers.sorted.all
retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
@ -64,9 +64,10 @@ class VersionsController < ApplicationController
def show def show
respond_to do |format| respond_to do |format|
format.html { format.html {
@issues = @version.fixed_issues.visible.find(:all, @issues = @version.fixed_issues.visible.
:include => [:status, :tracker, :priority], includes(:status, :tracker, :priority).
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id").
all
} }
format.api format.api
end end

View File

@ -64,7 +64,7 @@ class WatchersController < ApplicationController
end end
def autocomplete_for_user def autocomplete_for_user
@users = User.active.like(params[:q]).find(:all, :limit => 100) @users = User.active.like(params[:q]).limit(100).all
if @watched if @watched
@users -= @watched.watcher_users @users -= @watched.watcher_users
end end