Perform the where(...).first to find_by(...) refactoring.

This refactoring was automated using the command: bundle exec "ruby refactorings/where_dot_first_to_find_by/app.rb"
This commit is contained in:
Louis Rose
2014-05-06 14:41:59 +01:00
parent f1369e4503
commit 1574485443
104 changed files with 204 additions and 213 deletions

View File

@@ -137,7 +137,7 @@ class PostAlerter
# Returns a list of users who were quoted in the post
def extract_quoted_users(post)
post.raw.scan(/\[quote=\"([^,]+),.+\"\]/).uniq.map do |m|
User.where("username_lower = :username and id != :id", username: m.first.strip.downcase, id: post.user_id).first
User.find_by("username_lower = :username and id != :id", username: m.first.strip.downcase, id: post.user_id)
end.compact
end

View File

@@ -53,7 +53,7 @@ class UserDestroyer
categories.each do |c|
c.user_id = Discourse.system_user.id
c.save!
if topic = Topic.with_deleted.where(id: c.topic_id).first
if topic = Topic.with_deleted.find_by(id: c.topic_id)
topic.try(:recover!)
topic.user_id = Discourse.system_user.id
topic.save!