mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 08:03:40 +08:00
PERF: Remove unnecessary queries from Theme#set_field (#21281)
This commit is contained in:
parent
3527fbcd8e
commit
ae63d9ea09
|
@ -494,11 +494,11 @@ class Theme < ActiveRecord::Base
|
|||
|
||||
value ||= ""
|
||||
|
||||
field =
|
||||
theme_fields.find { |f| f.name == name && f.target_id == target_id && f.type_id == type_id }
|
||||
field = theme_fields.find_by(name: name, target_id: target_id, type_id: type_id)
|
||||
|
||||
if field
|
||||
if value.blank? && !upload_id
|
||||
theme_fields.delete field.destroy
|
||||
field.destroy
|
||||
else
|
||||
if field.value != value || field.upload_id != upload_id
|
||||
field.value = value
|
||||
|
|
Loading…
Reference in New Issue
Block a user