summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-03 21:30:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-12-03 21:30:10 +0000
commitea296a109a8655ea48c02c1d0a9bb0d19002d236 (patch)
tree08b5e517e77e341cfdd5a23d649dd1e754074dd4 /app
parenta7023dfa9b8e39e6e0a73e57d22823e8a4260b71 (diff)
downloadredmine-ea296a109a8655ea48c02c1d0a9bb0d19002d236.tar.gz
redmine-ea296a109a8655ea48c02c1d0a9bb0d19002d236.zip
Replaces find(:first/:all) calls.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10931 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_controller.rb5
-rw-r--r--app/controllers/boards_controller.rb19
-rw-r--r--app/controllers/documents_controller.rb2
-rw-r--r--app/controllers/trackers_controller.rb2
-rw-r--r--app/controllers/users_controller.rb5
-rw-r--r--app/controllers/wiki_controller.rb11
-rw-r--r--app/models/query.rb31
7 files changed, 42 insertions, 33 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index e8cccca85..a7a1b9a14 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -32,10 +32,9 @@ class AdminController < ApplicationController
def projects
@status = params[:status] || 1
- scope = Project.status(@status)
+ scope = Project.status(@status).order('lft')
scope = scope.like(params[:name]) if params[:name].present?
-
- @projects = scope.all(:order => 'lft')
+ @projects = scope.all
render :action => "projects", :layout => false if request.xhr?
end
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index cea2cd3bd..faf88647c 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -43,17 +43,22 @@ class BoardsController < ApplicationController
@topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
- @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all(
- :include => [:author, {:last_reply => :author}],
- :limit => @topic_pages.items_per_page,
- :offset => @topic_pages.current.offset)
+ @topics = @board.topics.
+ reorder("#{Message.table_name}.sticky DESC").
+ includes(:author, {:last_reply => :author}).
+ limit(@topic_pages.items_per_page).
+ offset(@topic_pages.current.offset).
+ order(sort_clause).
+ all
@message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr?
}
format.atom {
- @messages = @board.messages.find :all, :order => 'created_on DESC',
- :include => [:author, :board],
- :limit => Setting.feeds_limit.to_i
+ @messages = @board.messages.
+ reorder('created_on DESC').
+ includes(:author, :board).
+ limit(Setting.feeds_limit.to_i).
+ all
render_feed(@messages, :title => "#{@project}: #{@board}")
}
end
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 979fc6004..cf40d1293 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -27,7 +27,7 @@ class DocumentsController < ApplicationController
def index
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
- documents = @project.documents.find :all, :include => [:attachments, :category]
+ documents = @project.documents.includes(:attachments, :category).all
case @sort_by
when 'date'
@grouped = documents.group_by {|d| d.updated_on.to_date }
diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb
index 3c08e30a7..78c907053 100644
--- a/app/controllers/trackers_controller.rb
+++ b/app/controllers/trackers_controller.rb
@@ -36,7 +36,7 @@ class TrackersController < ApplicationController
def new
@tracker ||= Tracker.new(params[:tracker])
- @trackers = Tracker.find :all, :order => 'position'
+ @trackers = Tracker.sorted.all
@projects = Project.all
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 239bd290e..e6702a971 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -47,10 +47,7 @@ class UsersController < ApplicationController
@user_count = scope.count
@user_pages = Paginator.new self, @user_count, @limit, params['page']
@offset ||= @user_pages.current.offset
- @users = scope.find :all,
- :order => sort_clause,
- :limit => @limit,
- :offset => @offset
+ @users = scope.order(sort_clause).limit(@limit).offset(@offset).all
respond_to do |format|
format.html {
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 5d8d326ba..fd7076024 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -213,11 +213,12 @@ class WikiController < ApplicationController
@version_count = @page.content.versions.count
@version_pages = Paginator.new self, @version_count, per_page_option, params['page']
# don't load text
- @versions = @page.content.versions.find :all,
- :select => "id, author_id, comments, updated_on, version",
- :order => 'version DESC',
- :limit => @version_pages.items_per_page + 1,
- :offset => @version_pages.current.offset
+ @versions = @page.content.versions.
+ select("id, author_id, comments, updated_on, version").
+ reorder('version DESC').
+ limit(@version_pages.items_per_page + 1).
+ offset(@version_pages.current.offset).
+ all
render :layout => false if request.xhr?
end
diff --git a/app/models/query.rb b/app/models/query.rb
index 84f8c3ef6..409095434 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -685,12 +685,14 @@ class Query < ActiveRecord::Base
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
order_option = nil if order_option.blank?
- issues = Issue.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
- :conditions => statement,
- :order => order_option,
- :joins => joins_for_order_statement(order_option),
- :limit => options[:limit],
- :offset => options[:offset]
+ issues = Issue.visible.where(options[:conditions]).all(
+ :include => ([:status, :project] + (options[:include] || [])).uniq,
+ :conditions => statement,
+ :order => order_option,
+ :joins => joins_for_order_statement(order_option),
+ :limit => options[:limit],
+ :offset => options[:offset]
+ )
if has_column?(:spent_hours)
Issue.load_visible_spent_hours(issues)
@@ -721,11 +723,13 @@ class Query < ActiveRecord::Base
# Returns the journals
# Valid options are :order, :offset, :limit
def journals(options={})
- Journal.visible.find :all, :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
- :conditions => statement,
- :order => options[:order],
- :limit => options[:limit],
- :offset => options[:offset]
+ Journal.visible.all(
+ :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}],
+ :conditions => statement,
+ :order => options[:order],
+ :limit => options[:limit],
+ :offset => options[:offset]
+ )
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
@@ -733,7 +737,10 @@ class Query < ActiveRecord::Base
# Returns the versions
# Valid options are :conditions
def versions(options={})
- Version.visible.scoped(:conditions => options[:conditions]).find :all, :include => :project, :conditions => project_statement
+ Version.visible.where(options[:conditions]).all(
+ :include => :project,
+ :conditions => project_statement
+ )
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end