From af86099ac5e33ba418f1658d8bc47f4cbc427400 Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 2 Jun 2015 11:12:47 -0400 Subject: [PATCH] #1938 remove duplicates --- app/logical/post_sets/post.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index b5e17e672..0d9d349a2 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -82,7 +82,11 @@ module PostSets 3.times do missing = per_page - temp.length if missing >= 1 - temp += ::Post.tag_match(tag_string).where("random() < ?", chance*2).reorder("").limit(missing) + q = ::Post.tag_match(tag_string).where("random() < ?", chance*2).reorder("").limit(missing) + unless temp.empty? + q = q.where("id not in (?)", temp.map(&:id)) + end + temp += q end end elsif raw