logic to bypass trust level filter for high scoring posts

This commit is contained in:
Sam
2013-07-03 10:21:10 +10:00
parent ce0a7739cf
commit 4d4a5735d2
3 changed files with 26 additions and 3 deletions

View File

@ -161,7 +161,17 @@ class TopicView
min_trust_level = opts[:min_trust_level]
if min_trust_level && min_trust_level > 0
@posts = @posts.where('COALESCE(users.trust_level,0) >= ?', min_trust_level)
bypass_trust_level_score = opts[:bypass_trust_level_score]
if bypass_trust_level_score && bypass_trust_level_score > 0
@posts = @posts.where('COALESCE(users.trust_level,0) >= ? OR posts.score >= ?',
min_trust_level,
bypass_trust_level_score
)
else
@posts = @posts.where('COALESCE(users.trust_level,0) >= ?', min_trust_level)
end
end
min_score = opts[:min_score]
@ -169,6 +179,7 @@ class TopicView
@posts = @posts.where('posts.score >= ?', min_score)
end
@posts = @posts.to_a
@posts.sort!{|a,b| a.post_number <=> b.post_number}
@posts