diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-07-20 21:06:49 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-07-20 21:06:49 -0500 |
commit | 0dabcbfb02c09e7ece04b4aec822f152164ae67f (patch) | |
tree | ee1e75d6ef0fc597e29235e09ae95f1e4bb0411b /app/models | |
parent | 483f550f9c4f76f37d840f9f52cc85478fa86bf6 (diff) |
limit post search to own social graph
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/status.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index e9aa55eab..ec492293f 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -314,18 +314,15 @@ class Status < ApplicationRecord after_create :process_bangtags, if: :local? class << self - def search_for(term, limit = 66, account = nil) + def search_for(term, limit = 33, account = nil) + return none if account.nil? pattern = sanitize_sql_like(term) pattern = "#{pattern}" - scope = Status.where("tsv @@ plainto_tsquery('english', ?)", pattern) - query = scope.public_local_visibility - if account.present? - query = query - .or(scope.where(account: account)) - .or(scope.where(account: account.following, visibility: [:private, :unlisted])) - .or(scope.where(id: account.mentions.select(:status_id))) - end - query = query.where(reblog_of_id: nil).limit(limit) + scope = Status.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern) + query = scope.where(account: account) + .or(scope.where(account: account.following, visibility: [:private, :local, :unlisted])) + .or(scope.where(id: account.mentions.select(:status_id))) + .limit(limit) apply_timeline_filters(query, account, true) end |