Remove user from algolia index before destroy (#524)

This commit is contained in:
Ben Halpern 2018-06-29 14:26:31 -04:00 committed by GitHub
parent 92a541a517
commit 51228e929b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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