add upvote and downvote metatags

This commit is contained in:
r888888888
2016-09-08 17:48:50 -07:00
parent e56d71a7d2
commit c10176e64d
4 changed files with 25 additions and 3 deletions

View File

@@ -348,6 +348,18 @@ class PostQueryBuilder
end
end
if q[:upvote].present?
user_id = q[:upvote]
post_ids = PostVote.where(:user_id => user_id).where("score > 0").limit(400).pluck(:post_id)
relation = relation.where("posts.id in (?)", post_ids)
end
if q[:downvote].present?
user_id = q[:downvote]
post_ids = PostVote.where(:user_id => user_id).where("score < 0").limit(400).pluck(:post_id)
relation = relation.where("posts.id in (?)", post_ids)
end
if q[:ordfav].present?
user_id = q[:ordfav].to_i
user = User.find(user_id)