diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-24 22:22:00 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-24 22:22:00 -0500 |
commit | 363438a241e2c44077b83e29859b37af2714c1fe (patch) | |
tree | 57d03094b7d53dc9a9c36064f2cefff3804dbe80 /app | |
parent | 62e308d1b054c05ccf06402193e36099cf8c9292 (diff) |
support `offset` with search
Diffstat (limited to 'app')
-rw-r--r-- | app/models/status.rb | 4 | ||||
-rw-r--r-- | app/services/search_service.rb | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 4210a1815..0be747b00 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -335,7 +335,7 @@ class Status < ApplicationRecord after_create :process_bangtags, if: :local? class << self - def search_for(term, limit = 33, account = nil) + def search_for(term, account = nil, limit = 33, offset = 0) return none if account.nil? if term.start_with?('me:') term = term.split(nil, 2)[1] @@ -349,7 +349,7 @@ class Status < ApplicationRecord return none if term.blank? pattern = sanitize_sql_like(term) pattern = "#{pattern}" - query = query.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern).limit(limit) + query = query.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern).offset(offset).limit(limit) apply_timeline_filters(query, account, true) end diff --git a/app/services/search_service.rb b/app/services/search_service.rb index dda741bc4..ff6cc2197 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -23,7 +23,7 @@ class SearchService < BaseService private def search_for - results = Status.search_for(@query.gsub(/\A#/, ''), @limit, @account) + results = Status.search_for(@query.gsub(/\A#/, ''), @account, @limit, @offset) return results if results.empty? account_ids = results.pluck(:account_id) account_domains = results.map(&:account_domain) @@ -35,7 +35,7 @@ class SearchService < BaseService AccountSearchService.new.call( @query, @account, - limit: [@limit, 15].min, + limit: [@limit, 12].min, resolve: @resolve, offset: @offset ) |