FIX: Move user reindexing into a job (#26753)

In a large forum with millions of users and millions of user_fields
updating the list of dropdown user field options will result in a
502 now due to the large number of fields.

This commit moves the indexing into a job.
This commit is contained in:
Natalie Tay
2024-04-25 20:58:34 +08:00
committed by GitHub
parent c62d3610c6
commit 00a9369ca2
5 changed files with 48 additions and 3 deletions

View File

@ -30,4 +30,14 @@ RSpec.describe UserField do
expect(user_field.description).to eq(link)
end
it "enqueues index user fields job on save" do
user_field = Fabricate(:user_field)
user_field.update!(description: "tomtom")
expect(
job_enqueued?(job: Jobs::IndexUserFieldsForSearch, args: { user_field_id: user_field.id }),
).to eq(true)
end
end