From 1949a48070721762d716269b66bff2ecdfd5a637 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 30 May 2015 18:01:03 -0400 Subject: [PATCH] #1938 fill in blank spots --- app/logical/post_sets/post.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index ec1f0535c..b5e17e672 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -77,7 +77,14 @@ module PostSets chance = per_page / count.to_f end - temp = ::Post.tag_match(tag_string).where("random() < ?", chance).reorder("").limit(per_page) + temp = [] + temp += ::Post.tag_match(tag_string).where("random() < ?", chance).reorder("").limit(per_page) + 3.times do + missing = per_page - temp.length + if missing >= 1 + temp += ::Post.tag_match(tag_string).where("random() < ?", chance*2).reorder("").limit(missing) + end + end elsif raw temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page) else