mirror of
https://github.com/discourse/discourse.git
synced 2025-03-30 16:06:39 +08:00
FIX: N+1 query on topics view page.
This commit is contained in:
parent
bc28c1ccb5
commit
ced86aa890
@ -106,13 +106,19 @@ module I18n
|
|||||||
|
|
||||||
by_site = @overrides_by_site[site]
|
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] = {}
|
by_site = @overrides_by_site[site] = {}
|
||||||
|
|
||||||
# Load overrides
|
# Load overrides
|
||||||
TranslationOverride.where(locale: locale).pluck(:translation_key, :value).each do |tuple|
|
translations_overrides = TranslationOverride.where(locale: locale).pluck(:translation_key, :value)
|
||||||
by_locale = by_site[locale] ||= {}
|
|
||||||
by_locale[tuple[0]] = tuple[1]
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user