mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: N+1 query on topics view page.
This commit is contained in:
parent
90e017ffef
commit
8dad58ba78
1 changed files with 10 additions and 4 deletions
|
@ -106,13 +106,19 @@ module I18n
|
|||
|
||||
by_site = @overrides_by_site[site]
|
||||
|
||||
unless by_site && by_site.has_key?(locale)
|
||||
if by_site.nil? || !by_site.has_key?(locale)
|
||||
by_site = @overrides_by_site[site] = {}
|
||||
|
||||
# Load overrides
|
||||
TranslationOverride.where(locale: locale).pluck(:translation_key, :value).each do |tuple|
|
||||
by_locale = by_site[locale] ||= {}
|
||||
by_locale[tuple[0]] = tuple[1]
|
||||
translations_overrides = TranslationOverride.where(locale: locale).pluck(:translation_key, :value)
|
||||
|
||||
if translations_overrides.empty?
|
||||
by_site[locale] = {}
|
||||
else
|
||||
translations_overrides.each do |tuple|
|
||||
by_locale = by_site[locale] ||= {}
|
||||
by_locale[tuple[0]] = tuple[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue