forked from e621ng/e621ng
[Forum] Avoid a bunch of queries for votable posts
There were always at least 3, or 4 if you didn't vote yourself yet. Now it's always just 1.
This commit is contained in:
parent
22ad22da16
commit
3fe3c85cb6
@ -3,14 +3,17 @@
|
||||
# forum_post
|
||||
%>
|
||||
|
||||
<% votes.by(CurrentUser.user.id).each do |vote| %>
|
||||
<% own_vote = votes.find { |vote| vote.creator == CurrentUser.user } %>
|
||||
<% other_votes = votes.reject { |vote| vote.creator == CurrentUser.user } %>
|
||||
|
||||
<% if own_vote %>
|
||||
<%= render "forum_post_votes/vote", vote: own_vote, forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
||||
<% other_votes.each do |vote| %>
|
||||
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
||||
<% votes.excluding_user(CurrentUser.user.id).each do |vote| %>
|
||||
<%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
||||
<% if forum_post.tag_change_request&.is_pending? && !votes.by(CurrentUser.user.id).exists? %>
|
||||
<%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %>
|
||||
<% if forum_post.tag_change_request&.is_pending? && !own_vote %>
|
||||
<%= render "forum_post_votes/add_vote", forum_post: forum_post %>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user