mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 14:55:05 +08:00
PERF: eager load field changes (#27675)
Fix N+1 issue for javascript_cache stable backport for #27626
This commit is contained in:
parent
ee53f42c2c
commit
63c90e8c59
|
@ -697,7 +697,9 @@ class Theme < ActiveRecord::Base
|
|||
|
||||
def build_theme_uploads_hash
|
||||
hash = {}
|
||||
upload_fields.each do |field|
|
||||
upload_fields
|
||||
.includes(:javascript_cache, :upload)
|
||||
.each do |field|
|
||||
hash[field.name] = Discourse.store.cdn_url(field.upload.url) if field.upload&.url
|
||||
end
|
||||
hash
|
||||
|
@ -705,7 +707,9 @@ class Theme < ActiveRecord::Base
|
|||
|
||||
def build_local_theme_uploads_hash
|
||||
hash = {}
|
||||
upload_fields.each do |field|
|
||||
upload_fields
|
||||
.includes(:javascript_cache, :upload)
|
||||
.each do |field|
|
||||
hash[field.name] = field.javascript_cache.local_url if field.javascript_cache
|
||||
end
|
||||
hash
|
||||
|
@ -826,6 +830,8 @@ class Theme < ActiveRecord::Base
|
|||
if upload = field.upload
|
||||
url = upload_cdn_path(upload.url)
|
||||
contents << "$#{field.name}: unquote(\"#{url}\");"
|
||||
else
|
||||
contents << "$#{field.name}: unquote(\"\");"
|
||||
end
|
||||
else
|
||||
contents << to_scss_variable(field.name, field.value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user