PERF: Eager load field causing N+1 issue (#27626)
* PERF: Fix N+1 issue for javascript_cache * FIX: missing upload fields should still appear in stylesheets Sass is still expected to compile successfully even without uploads. Revert a blank upload to have a blank URL * DEV: remove unneeded test comment --------- Co-authored-by: Jeff Wong <awole20@gmail.com>
This commit is contained in:
parent
947990b7f6
commit
0acd6bea4c
|
@ -714,17 +714,21 @@ class Theme < ActiveRecord::Base
|
||||||
|
|
||||||
def build_theme_uploads_hash
|
def build_theme_uploads_hash
|
||||||
hash = {}
|
hash = {}
|
||||||
upload_fields.each do |field|
|
upload_fields
|
||||||
hash[field.name] = Discourse.store.cdn_url(field.upload.url) if field.upload&.url
|
.includes(:javascript_cache, :upload)
|
||||||
end
|
.each do |field|
|
||||||
|
hash[field.name] = Discourse.store.cdn_url(field.upload.url) if field.upload&.url
|
||||||
|
end
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_local_theme_uploads_hash
|
def build_local_theme_uploads_hash
|
||||||
hash = {}
|
hash = {}
|
||||||
upload_fields.each do |field|
|
upload_fields
|
||||||
hash[field.name] = field.javascript_cache.local_url if field.javascript_cache
|
.includes(:javascript_cache, :upload)
|
||||||
end
|
.each do |field|
|
||||||
|
hash[field.name] = field.javascript_cache.local_url if field.javascript_cache
|
||||||
|
end
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -843,6 +847,8 @@ class Theme < ActiveRecord::Base
|
||||||
if upload = field.upload
|
if upload = field.upload
|
||||||
url = upload_cdn_path(upload.url)
|
url = upload_cdn_path(upload.url)
|
||||||
contents << "$#{field.name}: unquote(\"#{url}\");"
|
contents << "$#{field.name}: unquote(\"#{url}\");"
|
||||||
|
else
|
||||||
|
contents << "$#{field.name}: unquote(\"\");"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
contents << to_scss_variable(field.name, field.value)
|
contents << to_scss_variable(field.name, field.value)
|
||||||
|
|
Loading…
Reference in New Issue