PERF: N+1 queries on badges page.

This commit is contained in:
Guo Xiang Tan
2018-03-19 14:36:09 +08:00
parent ec57ca54b5
commit c1bf707e7d

View File

@ -14,8 +14,8 @@ class BadgesController < ApplicationController
if (params[:only_listable] == "true") || !request.xhr? if (params[:only_listable] == "true") || !request.xhr?
# NOTE: this is sorted client side if needed # NOTE: this is sorted client side if needed
badges = badges.includes(:badge_grouping) badges = badges.includes(:badge_grouping)
.includes(:badge_type)
.where(enabled: true, listable: true) .where(enabled: true, listable: true)
end end
badges = badges.to_a badges = badges.to_a