Permalink
Browse files

simplify Story.find_similar_by_url arel, only pull undeleted stories

  • Loading branch information...
jcs committed Mar 28, 2014
1 parent f647e62 commit 7fb75af7fec5c3da4c8f7d6f2fb03be22fae7a81
Showing with 1 addition and 7 deletions.
  1. +1 −7 app/models/story.rb
View
@@ -74,13 +74,7 @@ def self.find_similar_by_url(url)
end
urls = urls2.clone
conds = [ "" ]
urls.uniq.each_with_index do |u,x|
conds[0] << (x == 0 ? "" : " OR ") << "url = ?"
conds.push u
end
if s = Story.where(*conds).order("id DESC").first
if s = Story.where(:url => urls, :is_expired => false).order("id DESC").first
return s
end

0 comments on commit 7fb75af

Please sign in to comment.