Use full-text search for autosuggestions
This commit is contained in:
parent
cd765f26a9
commit
09218d4c01
14 changed files with 153 additions and 39 deletions
|
@ -1,5 +1,6 @@
|
|||
class Account < ApplicationRecord
|
||||
include Targetable
|
||||
include PgSearch
|
||||
|
||||
MENTION_RE = /(?:^|[^\/\w])@([a-z0-9_]+(?:@[a-z0-9\.\-]+)?)/i
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
||||
|
@ -42,6 +43,8 @@ class Account < ApplicationRecord
|
|||
|
||||
has_many :media_attachments, dependent: :destroy
|
||||
|
||||
pg_search_scope :search_for, against: %i(username domain), using: { tsearch: { prefix: true } }
|
||||
|
||||
scope :remote, -> { where.not(domain: nil) }
|
||||
scope :local, -> { where(domain: nil) }
|
||||
scope :without_followers, -> { where('(select count(f.id) from follows as f where f.target_account_id = accounts.id) = 0') }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue