diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index cacad9d82..5bf458287 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -473,14 +473,12 @@ class PostQueryBuilder 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) + post_ids = PostVote.where(user: q[:upvote]).where("score > 0").select(:post_id) relation = relation.where("posts.id": 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) + post_ids = PostVote.where(user: q[:downvote]).where("score < 0").select(:post_id) relation = relation.where("posts.id": post_ids) end diff --git a/app/models/tag.rb b/app/models/tag.rb index 16d7bacdf..c1c74e58f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -774,13 +774,17 @@ class Tag < ApplicationRecord end when "upvote" - if CurrentUser.user.is_moderator? - q[:upvote] = User.name_to_id(g2) + if CurrentUser.user.is_admin? + q[:upvote] = User.find_by_name(g2) + elsif CurrentUser.user.is_voter? + q[:upvote] = CurrentUser.user end when "downvote" - if CurrentUser.user.is_moderator? - q[:downvote] = User.name_to_id(g2) + if CurrentUser.user.is_admin? + q[:downvote] = User.find_by_name(g2) + elsif CurrentUser.user.is_voter? + q[:downvote] = CurrentUser.user end when *COUNT_METATAGS diff --git a/app/views/users/_statistics.html.erb b/app/views/users/_statistics.html.erb index 611440e75..1416c5129 100644 --- a/app/views/users/_statistics.html.erb +++ b/app/views/users/_statistics.html.erb @@ -85,6 +85,15 @@ + <% if CurrentUser.user == user || CurrentUser.user.is_admin? %> +