]> source.dussan.org Git - redmine.git/commitdiff
Replaces find(:all) calls.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Dec 2012 19:09:42 +0000 (19:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Dec 2012 19:09:42 +0000 (19:09 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10914 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/custom_fields_controller.rb
app/controllers/documents_controller.rb
app/controllers/messages_controller.rb
app/controllers/projects_controller.rb
app/controllers/reports_controller.rb
app/controllers/repositories_controller.rb
app/controllers/trackers_controller.rb
app/controllers/users_controller.rb
app/controllers/versions_controller.rb
app/controllers/watchers_controller.rb

index 96f2518bb9c5ff137cdff66024c3c643e713fd1e..fb03277a78ffcde405594b45ff74317f3431cfe9 100644 (file)
@@ -23,7 +23,7 @@ class CustomFieldsController < ApplicationController
   before_filter :find_custom_field, :only => [:edit, :update, :destroy]
 
   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'
   end
 
index b3c82eeb0326c53b8b435c583255463d077db940..979fc6004fe537df4832be6f647f600584f140ec 100644 (file)
@@ -43,7 +43,7 @@ class DocumentsController < ApplicationController
   end
 
   def show
-    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
+    @attachments = @document.attachments.all
   end
 
   def new
index d4c388c22c33e7fc0dfbe72a62be8527b70f8071..16e3b7c45d3423b2a038fc1294138fac081d2bbb 100644 (file)
@@ -40,10 +40,12 @@ class MessagesController < ApplicationController
 
     @reply_count = @topic.children.count
     @reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page
-    @replies =  @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}],
-                                           :order => "#{Message.table_name}.created_on ASC",
-                                           :limit => @reply_pages.items_per_page,
-                                           :offset => @reply_pages.current.offset)
+    @replies =  @topic.children.
+      includes(:author, :attachments, {:board => :project}).
+      reorder("#{Message.table_name}.created_on ASC").
+      limit(@reply_pages.items_per_page).
+      offset(@reply_pages.current.offset).
+      all
 
     @reply = Message.new(:subject => "RE: #{@message.subject}")
     render :action => "show", :layout => false if request.xhr?
index 3c1e6ba0a73fb83c473af05e79db02d2d49cec3b..c8222db735b7484459df88569fe2c31b5bee93fa 100644 (file)
@@ -57,11 +57,10 @@ class ProjectsController < ApplicationController
       format.api  {
         @offset, @limit = api_offset_and_limit
         @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 {
-        projects = Project.visible.find(:all, :order => 'created_on DESC',
-                                              :limit => Setting.feeds_limit.to_i)
+        projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
         render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
       }
     end
@@ -145,7 +144,7 @@ class ProjectsController < ApplicationController
 
     @users_by_role = @project.users_by_role
     @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
 
     cond = @project.project_condition(Setting.display_subprojects_issues?)
index c9e9a39fa5d393f8090d83ad7dae76aeee26d211..7b8e37aee907a6bc84ac5bc11329fb862b186135 100644 (file)
@@ -90,6 +90,6 @@ class ReportsController < ApplicationController
   private
 
   def find_issue_statuses
-    @statuses = IssueStatus.find(:all, :order => 'position')
+    @statuses = IssueStatus.sorted.all
   end
 end
index 0a453a07cfe3631ec01cd09d62d4755064067c6d..5f5eb5e6ffff2f70e192ba548cb75577ab7ca40c 100644 (file)
@@ -141,10 +141,11 @@ class RepositoriesController < ApplicationController
     @changeset_pages = Paginator.new self, @changeset_count,
                                      per_page_option,
                                      params['page']
-    @changesets = @repository.changesets.find(:all,
-                       :limit  =>  @changeset_pages.items_per_page,
-                       :offset =>  @changeset_pages.current.offset,
-                       :include => [:user, :repository, :parents])
+    @changesets = @repository.changesets.
+      limit(@changeset_pages.items_per_page).
+      offset(@changeset_pages.current.offset).
+      includes(:user, :repository, :parents).
+      all
 
     respond_to do |format|
       format.html { render :layout => false if request.xhr? }
index 02f91eaab79566af9a26831def46580d390f1e36..3c08e30a7aeed0ae807ca6a495c1ead3347e4ecf 100644 (file)
@@ -37,7 +37,7 @@ class TrackersController < ApplicationController
   def new
     @tracker ||= Tracker.new(params[:tracker])
     @trackers = Tracker.find :all, :order => 'position'
-    @projects = Project.find(:all)
+    @projects = Project.all
   end
 
   def create
@@ -57,7 +57,7 @@ class TrackersController < ApplicationController
 
   def edit
     @tracker ||= Tracker.find(params[:id])
-    @projects = Project.find(:all)
+    @projects = Project.all
   end
 
   def update
index da6f6ae28971927b09a7f686dc69d214f817811f..239bd290eb9d52f32ddc88d64bfa0ffae9217164 100644 (file)
@@ -83,7 +83,7 @@ class UsersController < ApplicationController
 
   def new
     @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
-    @auth_sources = AuthSource.find(:all)
+    @auth_sources = AuthSource.all
   end
 
   def create
@@ -112,7 +112,7 @@ class UsersController < ApplicationController
         format.api  { render :action => 'show', :status => :created, :location => user_url(@user) }
       end
     else
-      @auth_sources = AuthSource.find(:all)
+      @auth_sources = AuthSource.all
       # Clear password input
       @user.password = @user.password_confirmation = nil
 
@@ -124,7 +124,7 @@ class UsersController < ApplicationController
   end
 
   def edit
-    @auth_sources = AuthSource.find(:all)
+    @auth_sources = AuthSource.all
     @membership ||= Member.new
   end
 
@@ -159,7 +159,7 @@ class UsersController < ApplicationController
         format.api  { render_api_ok }
       end
     else
-      @auth_sources = AuthSource.find(:all)
+      @auth_sources = AuthSource.all
       @membership ||= Member.new
       # Clear password input
       @user.password = @user.password_confirmation = nil
index 852f7a59003c99faf79d4053908901aff761290a..9777c0537878b1efe4e9276e56dc8f8ffbd8fe4f 100644 (file)
@@ -31,7 +31,7 @@ class VersionsController < ApplicationController
   def index
     respond_to do |format|
       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?})
         @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]
@@ -64,9 +64,10 @@ class VersionsController < ApplicationController
   def show
     respond_to do |format|
       format.html {
-        @issues = @version.fixed_issues.visible.find(:all,
-          :include => [:status, :tracker, :priority],
-          :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id")
+        @issues = @version.fixed_issues.visible.
+          includes(:status, :tracker, :priority).
+          reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id").
+          all
       }
       format.api
     end
index a0be20faf9125fdcd7b7708a84f751383e205108..278ca1bc55203203881eeb4aa05235eebba282be 100644 (file)
@@ -64,7 +64,7 @@ class WatchersController < ApplicationController
   end
 
   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
       @users -= @watched.watcher_users
     end