feat(search): add unified global search for users/chats/messages
Some checks failed
CI / test (push) Failing after 24s
Some checks failed
CI / test (push) Failing after 24s
This commit is contained in:
30
app/search/router.py
Normal file
30
app/search/router.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.auth.service import get_current_user
|
||||
from app.database.session import get_db
|
||||
from app.search.schemas import GlobalSearchRead
|
||||
from app.search.service import global_search
|
||||
from app.users.models import User
|
||||
|
||||
router = APIRouter(prefix="/search", tags=["search"])
|
||||
|
||||
|
||||
@router.get("", response_model=GlobalSearchRead)
|
||||
async def global_search_endpoint(
|
||||
query: str,
|
||||
users_limit: int = 10,
|
||||
chats_limit: int = 10,
|
||||
messages_limit: int = 10,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
) -> GlobalSearchRead:
|
||||
return await global_search(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
query=query,
|
||||
users_limit=users_limit,
|
||||
chats_limit=chats_limit,
|
||||
messages_limit=messages_limit,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user