diff options
author | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
commit | e159928e6b81c02001411e7e886208533178c0ba (patch) | |
tree | 41c78911f17078c798e5fdc1362b7c18aff138d2 /app/models/repository | |
parent | 323ef3182bc45184c7a14e3a8dc7244850baabed (diff) | |
download | redmine-e159928e6b81c02001411e7e886208533178c0ba.tar.gz redmine-e159928e6b81c02001411e7e886208533178c0ba.zip |
Use find_by instead of where.first to remove unnecessary sorting (#26747).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17586 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository')
-rw-r--r-- | app/models/repository/git.rb | 4 | ||||
-rw-r--r-- | app/models/repository/mercurial.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb index 4cb16e524..e48d36490 100644 --- a/app/models/repository/git.rb +++ b/app/models/repository/git.rb @@ -45,7 +45,7 @@ class Repository::Git < Repository return false if v.nil? v.to_s != '0' end - + def report_last_commit=(arg) merge_extra_info "extra_report_last_commit" => arg end @@ -89,7 +89,7 @@ class Repository::Git < Repository def find_changeset_by_name(name) if name.present? - changesets.where(:revision => name.to_s).first || + changesets.find_by(:revision => name.to_s) || changesets.where('scmid LIKE ?', "#{name}%").first end end diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index 922893a6a..2a8079ca0 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -99,7 +99,7 @@ class Repository::Mercurial < Repository if /[^\d]/ =~ s or s.size > 8 cs = changesets.where(:scmid => s).first else - cs = changesets.where(:revision => s).first + cs = changesets.find_by(:revision => s) end return cs if cs changesets.where('scmid LIKE ?', "#{s}%").first |