about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb3
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') }