/moderator/dashboard: optimize sql queries
* Converts queries to use active record instead of raw sql. This ensures that user objects are loaded by rails in the join, so that we don't have to issue `User.find` calls to load users one-by-one. * Use `.includes` to preload associations used in the view, to avoid additional N+1 query problems (primarily, calls to link_to_user also causing users to be loaded one-by-one).
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @dashboard.appeals.each do |appeal| %>
|
||||
<% @dashboard.appeals.each do |post| %>
|
||||
<tr>
|
||||
<td><%= link_to image_tag(appeal.post.preview_file_url), post_path(appeal.post) %></td>
|
||||
<td><%= mod_link_to_user appeal.post.uploader, :negative %></td>
|
||||
<td><%= post_flag_reasons(appeal.post) %></td>
|
||||
<td><%= post_appeal_reasons(appeal.post) %></td>
|
||||
<td><%= appeal.post.score %></td>
|
||||
<td><%= link_to image_tag(post.preview_file_url), post_path(post) %></td>
|
||||
<td><%= mod_link_to_user post.uploader, :negative %></td>
|
||||
<td><%= post_flag_reasons(post) %></td>
|
||||
<td><%= post_appeal_reasons(post) %></td>
|
||||
<td><%= post.score %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user