simplify Story.find_similar_by_url arel, only pull undeleted stories
This commit is contained in:
parent
f647e62f5f
commit
7fb75af7fe
|
@ -74,13 +74,7 @@ class Story < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
urls = urls2.clone
|
urls = urls2.clone
|
||||||
|
|
||||||
conds = [ "" ]
|
if s = Story.where(:url => urls, :is_expired => false).order("id DESC").first
|
||||||
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
|
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue