docbrown/app/models/concerns/algolia_searchable/searchable_user.rb
Ben Halpern b3b0eafe76
Implement MVP frontend for Algolia search (#20909)
* Add proper frontend for Algolia search

* Update app/models/concerns/algolia_searchable/searchable_comment.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/models/concerns/algolia_searchable/searchable_article.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix formatting

* Fix: copy to clipboard message (#20898)

* fix: copy to clipboard message

* chore: deletion of unused imports

* Pick winner in header field test (#20911)

* Updated the twitter icon to X icon - solved icon issue #20356  (#20910)

* changed the twitter icon to X icon in assets/images/twitter.svg

* Changed the twitter icon to X in assets/images/twitter.svg

* Add field test for Digest article list design (#20912)

* Add field test for Digest article list design

* Add check for cached user

* Include cached user in select (#20913)

* Include cached user in select

* Add tags

* update style for new follower email (#20908)

* Fix #19037 (#20917)

* Add alternate returns for html

* Remove console log

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Iasmim Pereira <100351576+IasmimCristina@users.noreply.github.com>
Co-authored-by: Darshan Padia <darshanpadia5@gmail.com>
Co-authored-by: Philip How <philip.j.how@gmail.com>
2024-05-06 15:20:53 -04:00

27 lines
898 B
Ruby

module AlgoliaSearchable
module SearchableUser
extend ActiveSupport::Concern
included do
algoliasearch(**DEFAULT_ALGOLIA_SETTINGS, unless: :bad_actor?) do
attribute :name, :username
add_attribute(:profile_image) { { url: profile_image_90 } }
# add_attribute(:profile_image_90) { profile_image_90 }
add_attribute(:timestamp) { registered_at.to_i }
add_replica("User_timestamp_desc", per_environment: true) { customRanking ["desc(timestamp)"] }
add_replica("User_timestamp_asc", per_environment: true) { customRanking ["asc(timestamp)"] }
end
end
class_methods do
def trigger_sidekiq_worker(record, delete)
AlgoliaSearch::SearchIndexWorker.perform_async(record.class.name, record.id, delete)
end
end
def bad_actor?
score.negative? || banished? || spam_or_suspended?
end
end
end