summaryrefslogtreecommitdiffstats
path: root/app/models/repository
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
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')
-rw-r--r--app/models/repository/bazaar.rb14
-rw-r--r--app/models/repository/cvs.rb21
-rw-r--r--app/models/repository/git.rb17
3 files changed, 17 insertions, 35 deletions
diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb
index ea20fe37d..135be83ca 100644
--- a/app/models/repository/bazaar.rb
+++ b/app/models/repository/bazaar.rb
@@ -68,15 +68,11 @@ class Repository::Bazaar < Repository
full_path = File.join(root_url, e.path)
e.size = File.stat(full_path).size if File.file?(full_path)
end
- c = Change.find(
- :first,
- :include => :changeset,
- :conditions => [
- "#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?",
- e.lastrev.revision,
- id
- ],
- :order => "#{Changeset.table_name}.revision DESC")
+ c = Change.
+ includes(:changeset).
+ where("#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id).
+ order("#{Changeset.table_name}.revision DESC").
+ first
if c
e.lastrev.identifier = c.changeset.revision
e.lastrev.name = c.changeset.revision
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index 155ac10ed..7bae8c091 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -143,14 +143,11 @@ class Repository::Cvs < Repository
)
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
author_utf8 = Changeset.to_utf8(revision.author, repo_log_encoding)
- cs = changesets.find(
- :first,
- :conditions => {
- :committed_on => tmp_time - time_delta .. tmp_time + time_delta,
- :committer => author_utf8,
- :comments => cmt
- }
- )
+ cs = changesets.where(
+ :committed_on => tmp_time - time_delta .. tmp_time + time_delta,
+ :committer => author_utf8,
+ :comments => cmt
+ ).first
# create a new changeset....
unless cs
# we use a temporaray revision number here (just for inserting)
@@ -185,10 +182,10 @@ class Repository::Cvs < Repository
end
# Renumber new changesets in chronological order
- Changeset.all(
- :order => 'committed_on ASC, id ASC',
- :conditions => ["repository_id = ? AND revision LIKE 'tmp%'", id]
- ).each do |changeset|
+ Changeset.
+ order('committed_on ASC, id ASC').
+ where("repository_id = ? AND revision LIKE 'tmp%'", id).
+ each do |changeset|
changeset.update_attribute :revision, next_revision_number
end
end # transaction
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index c1f0020eb..9b3617ba9 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -191,13 +191,8 @@ class Repository::Git < Repository
offset = 0
revisions_copy = revisions.clone # revisions will change
while offset < revisions_copy.size
- recent_changesets_slice = changesets.find(
- :all,
- :conditions => [
- 'scmid IN (?)',
- revisions_copy.slice(offset, limit).map{|x| x.scmid}
- ]
- )
+ scmids = revisions_copy.slice(offset, limit).map{|x| x.scmid}
+ recent_changesets_slice = changesets.where(:scmid => scmids).all
# Subtract revisions that redmine already knows about
recent_revisions = recent_changesets_slice.map{|c| c.scmid}
revisions.reject!{|r| recent_revisions.include?(r.scmid)}
@@ -246,13 +241,7 @@ class Repository::Git < Repository
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
return [] if revisions.nil? || revisions.empty?
- changesets.find(
- :all,
- :conditions => [
- "scmid IN (?)",
- revisions.map!{|c| c.scmid}
- ]
- )
+ changesets.where(:scmid => revisions.map {|c| c.scmid}).all
end
def clear_extra_info_of_changesets