Class: SaasPlatform::SearchService

Inherits:
Object
  • Object
show all
Defined in:
app/services/saas_platform/search_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(account, query) ⇒ SearchService

Returns a new instance of SearchService.



3
4
5
6
# File 'app/services/saas_platform/search_service.rb', line 3

def initialize(, query)
  @account = 
  @query = query
end

Instance Method Details

#performObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/saas_platform/search_service.rb', line 8

def perform
  return {} if @query.blank?

  ActsAsTenant.with_tenant(@account) do
    {
      users: SaasPlatform::User.search_by_name(@query).limit(5),
      products: SaasPlatform::Product.search_by_name(@query).limit(5),
      orders: SaasPlatform::Order.where(id: @query.to_i).limit(5) # Simple ID search for orders
    }
  end
end