simplify Story.find_similar_by_url arel, only pull undeleted stories

This commit is contained in:
joshua stein 2014-03-28 10:45:01 -05:00
parent f647e62f5f
commit 7fb75af7fe

View file

@ -74,13 +74,7 @@ class Story < ActiveRecord::Base
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