summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-06-12 19:13:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-06-12 19:13:25 +0000
commitf9ddb562d58ae98bcc69f74396b028cbc8cce0b1 (patch)
tree8019be9178fb3d14c764c04e3e3a5be955de1385 /app/models/repository.rb
parent136cdc765afda57b9be02704e52b27334da42c73 (diff)
downloadredmine-f9ddb562d58ae98bcc69f74396b028cbc8cce0b1.tar.gz
redmine-f9ddb562d58ae98bcc69f74396b028cbc8cce0b1.zip
Cleanup of finders with :conditions option.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11963 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index b0e946365..de3ca99a6 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -249,19 +249,18 @@ class Repository < ActiveRecord::Base
# Default behaviour is to search in cached changesets
def latest_changesets(path, rev, limit=10)
if path.blank?
- changesets.find(
- :all,
- :include => :user,
- :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
- :limit => limit)
+ changesets.
+ reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
+ limit(limit).
+ preload(:user).
+ all
else
- filechanges.find(
- :all,
- :include => {:changeset => :user},
- :conditions => ["path = ?", path.with_leading_slash],
- :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
- :limit => limit
- ).collect(&:changeset)
+ filechanges.
+ where("path = ?", path.with_leading_slash).
+ reorder("#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC").
+ limit(limit).
+ preload(:changeset => :user).
+ collect(&:changeset)
end
end
@@ -393,7 +392,7 @@ class Repository < ActiveRecord::Base
end
def set_as_default?
- new_record? && project && !Repository.first(:conditions => {:project_id => project.id})
+ new_record? && project && Repository.where(:project_id => project.id).empty?
end
protected