#1938 remove duplicates, remember &random and &raw params

This commit is contained in:
Toks
2015-05-18 14:10:44 -04:00
parent 0d24a45855
commit a5feec8ec6
2 changed files with 11 additions and 1 deletions

View File

@@ -74,7 +74,11 @@ module PostSets
temp = []
limit = [per_page, count].min
limit.times do
post = ::Post.tag_match(tag_string).offset(rand(count)).first
q = ::Post.tag_match(tag_string)
unless temp.empty?
q = q.where("id not in (?)", temp.map(&:id))
end
post = q.offset(rand(count - temp.length)).first
if post
temp << post
end