users: drop id_to_name, name_to_id caching.
Changes: * Drop Users.id_to_name. * Don't cache Users.name_to_id. * Replace calls to name_to_id with find_by_name when possible. * Don't autodefine creator_name in belongs_to_creator. * Don't autodefine updater_name in belongs_to_updater. * Instead manually define creator_name / updater_name only on models that need to return these fields in the api. id_to_name was cached to reduce the impact of N+1 query patterns in certain places, especially in api responses that return creator_name / updater_name fields. But it still meant we were doing N calls to memcache. Using `includes` to prefetch users avoids this N+1 pattern. name_to_id had no need be cached, it was never used in any performance- sensitive contexts. Avoiding caching also avoids the need to keep these caches consistent.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<% @uploads.each do |upload| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= PostPresenter.preview(upload.post, tags: "user:#{upload.uploader_name}", show_deleted: true) %>
|
||||
<%= PostPresenter.preview(upload.post, tags: "user:#{upload.uploader.name}", show_deleted: true) %>
|
||||
</td>
|
||||
<td class="col-expand upload-info">
|
||||
<span class="info">
|
||||
@@ -62,7 +62,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to_user upload.uploader %>
|
||||
<%= link_to "»", uploads_path(search: params[:search].merge(uploader_name: upload.uploader_name)) %>
|
||||
<%= link_to "»", uploads_path(search: params[:search].merge(uploader_name: upload.uploader.name)) %>
|
||||
<br><%= time_ago_in_words_tagged upload.created_at %>
|
||||
</td>
|
||||
<td class="col-normal">
|
||||
|
||||
Reference in New Issue
Block a user