mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Cache categories in Site model take 3.
Previous attempt resulted in custom fields going missing in the
serialized output.
This reverts commit 83a6ad32ff.
This commit is contained in:
@@ -142,6 +142,11 @@ module HasCustomFields
|
||||
super
|
||||
end
|
||||
|
||||
def on_custom_fields_change
|
||||
# Callback when custom fields have changed
|
||||
# Override in model
|
||||
end
|
||||
|
||||
def custom_fields_preloaded?
|
||||
!!@preloaded_custom_fields
|
||||
end
|
||||
@@ -197,8 +202,11 @@ module HasCustomFields
|
||||
if row_count == 0
|
||||
_custom_fields.create!(name: k, value: v)
|
||||
end
|
||||
|
||||
custom_fields[k.to_s] = v # We normalize custom_fields as strings
|
||||
end
|
||||
|
||||
on_custom_fields_change
|
||||
end
|
||||
|
||||
def save_custom_fields(force = false)
|
||||
@@ -253,6 +261,7 @@ module HasCustomFields
|
||||
end
|
||||
end
|
||||
|
||||
on_custom_fields_change
|
||||
refresh_custom_fields_from_db
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user