Remove user from algolia index before destroy (#524)
This commit is contained in:
parent
92a541a517
commit
51228e929b
1 changed files with 5 additions and 0 deletions
|
|
@ -87,6 +87,7 @@ class User < ApplicationRecord
|
|||
before_validation :set_username
|
||||
before_validation :downcase_email
|
||||
before_validation :check_for_username_change
|
||||
before_destroy :remove_from_algolia_index
|
||||
|
||||
algoliasearch per_environment: true, enqueue: :trigger_delayed_index do
|
||||
attribute :name
|
||||
|
|
@ -455,4 +456,8 @@ class User < ApplicationRecord
|
|||
score = (((articles_count + comments_count + reactions_count) * 10) + tag_keywords_for_search.size) * reputation_modifier * followers_count
|
||||
score.to_i
|
||||
end
|
||||
|
||||
def remove_from_algolia_index
|
||||
remove_from_index!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue