forked from e621ng/e621ng
[Comments] Simplify hidden
method
Instead of having the cognitive load of checking if this is indeed the inverse of `visible`, just wrap it all in sql not I'd love to have rails take care of this but haven't found something for that
This commit is contained in:
parent
c4bd8e961f
commit
9ec5ab3e1d
@ -36,9 +36,9 @@ class Comment < ApplicationRecord
|
||||
|
||||
def hidden(user)
|
||||
if user.is_moderator?
|
||||
where("score < ? and is_sticky = false", user.comment_threshold)
|
||||
where("not(score >= ? or is_sticky = true)", user.comment_threshold)
|
||||
else
|
||||
where("(score < ? and is_sticky = false) or (is_hidden = true and creator_id != ?)", user.comment_threshold, user.id)
|
||||
where("not((score >= ? or is_sticky = true) and (is_hidden = false or creator_id = ?))", user.comment_threshold, user.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user