mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
PERF: avoid extra object created on each User#validatable_user_fields call (#17556)
This commit is contained in:
parent
cc515e2c1c
commit
aad1e76150
@ -1257,7 +1257,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
USER_FIELD_PREFIX ||= "user_field_"
|
||||
|
||||
def user_fields(field_ids = nil, exclude_types: [])
|
||||
def user_fields(field_ids = nil)
|
||||
if field_ids.nil?
|
||||
field_ids = (@all_user_field_ids ||= UserField.pluck(:id))
|
||||
end
|
||||
@ -1288,10 +1288,9 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def validatable_user_fields
|
||||
# ignore multiselect fields since they are admin-set and thus not UGC
|
||||
relation = UserField.public_fields.where.not(field_type: 'multiselect')
|
||||
# ignore multiselect fields since they are admin-set and thus not user generated content
|
||||
@public_user_field_ids ||= UserField.public_fields.where.not(field_type: 'multiselect').pluck(:id)
|
||||
|
||||
@public_user_field_ids ||= relation.pluck(:id)
|
||||
user_fields(@public_user_field_ids)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user