diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-12 14:33:21 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-12 14:36:10 +0100 |
commit | 09218d4c0152013750dd1c127d3c8267dc45f880 (patch) | |
tree | 7cd9975b84a28de92403c80f483d08e471b10155 /app/models | |
parent | cd765f26a9610e160ffd347637fca40d7b80164e (diff) |
Use full-text search for autosuggestions
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 4fb0baebe..19300f48b 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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') } |