Added link/PreviewCard search to search
• Added: - link/PreviewCard search to search
This commit is contained in:
@@ -57,6 +57,14 @@ class PreviewCard < ApplicationRecord
|
||||
end
|
||||
|
||||
class << self
|
||||
def search_for(term, limit = 100, 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)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def image_styles(f)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Search < ActiveModelSerializers::Model
|
||||
attributes :accounts, :statuses, :hashtags, :groups
|
||||
attributes :accounts, :statuses, :hashtags, :groups, :links
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user