Updated SearchService Group, PreviewCard, Tag to be limit to 25
• Updated: - SearchService Group, PreviewCard, Tag to be limit to 25
This commit is contained in:
parent
8a1f2f2c47
commit
6e45eb18ca
@ -61,12 +61,12 @@ class Group < ApplicationRecord
|
||||
after_create :add_owner_to_accounts
|
||||
|
||||
class << self
|
||||
def search_for(term, limit = 25, offset = 0)
|
||||
def search_for(term, offset = 0)
|
||||
pattern = sanitize_sql_like(term.strip) + '%'
|
||||
|
||||
Group.where('lower(title) like lower(?) AND is_archived=false AND is_visible=true', pattern)
|
||||
.order('member_count DESC')
|
||||
.limit(limit)
|
||||
.limit(25)
|
||||
.offset(offset)
|
||||
end
|
||||
end
|
||||
|
@ -57,12 +57,12 @@ class PreviewCard < ApplicationRecord
|
||||
end
|
||||
|
||||
class << self
|
||||
def search_for(term, limit = 25, offset = 0)
|
||||
def search_for(term, offset = 0)
|
||||
pattern = '%' + sanitize_sql_like(term.strip) + '%'
|
||||
|
||||
PreviewCard.where(
|
||||
"lower(title) LIKE lower('#{pattern}') OR lower(description) LIKE lower('#{pattern}') OR lower(url) LIKE lower('#{pattern}')"
|
||||
).order('updated_at DESC').limit(limit).offset(offset)
|
||||
).order('updated_at DESC').limit(25).offset(offset)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -65,12 +65,12 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
class << self
|
||||
def search_for(term, limit = 5, offset = 0)
|
||||
def search_for(term, offset = 0)
|
||||
pattern = sanitize_sql_like(term.strip) + '%'
|
||||
|
||||
Tag.where('lower(name) like lower(?)', pattern)
|
||||
.order(:name)
|
||||
.limit(limit)
|
||||
.limit(25)
|
||||
.offset(offset)
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,6 @@ class SearchService < BaseService
|
||||
def perform_groups_search!
|
||||
Group.search_for(
|
||||
@query.gsub(/\A#/, ''),
|
||||
@limit,
|
||||
@offset
|
||||
)
|
||||
end
|
||||
@ -49,7 +48,6 @@ class SearchService < BaseService
|
||||
def perform_links_search!
|
||||
PreviewCard.search_for(
|
||||
@query.gsub(/\A#/, ''),
|
||||
@limit,
|
||||
@offset
|
||||
)
|
||||
end
|
||||
@ -82,7 +80,6 @@ class SearchService < BaseService
|
||||
def perform_hashtags_search!
|
||||
Tag.search_for(
|
||||
@query.gsub(/\A#/, ''),
|
||||
@limit,
|
||||
@offset
|
||||
)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user