* 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>
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
module AlgoliaSearchable
|
|
module SearchableComment
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
include AlgoliaSearch
|
|
|
|
algoliasearch(**DEFAULT_ALGOLIA_SETTINGS, unless: :bad_comment?) do
|
|
attribute :commentable_id, :commentable_type, :path, :parent_id, :title
|
|
attribute :body do
|
|
title
|
|
end
|
|
|
|
attribute :published_at do
|
|
readable_publish_date
|
|
end
|
|
|
|
attribute :user do
|
|
{ name: user.name,
|
|
username: user.username,
|
|
profile_image: user.profile_image_90,
|
|
profile_image_90: user.profile_image_90 }
|
|
end
|
|
|
|
add_attribute(:timestamp) { created_at.to_i }
|
|
add_replica("Comment_timestamp_desc", per_environment: true) { customRanking ["desc(timestamp)"] }
|
|
add_replica("Comment_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_comment?
|
|
score.negative?
|
|
end
|
|
end
|
|
end
|