mirror of
https://github.com/open-webui/open-webui
synced 2025-02-22 13:18:25 +00:00
add: skip and limit use in query
- limit default changed to -1
This commit is contained in:
parent
49199819db
commit
519375b4c0
@ -250,7 +250,7 @@ class ChatTable:
|
|||||||
user_id: str,
|
user_id: str,
|
||||||
include_archived: bool = False,
|
include_archived: bool = False,
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 50,
|
limit: int = -1,
|
||||||
) -> List[ChatTitleIdResponse]:
|
) -> List[ChatTitleIdResponse]:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
query = db.query(Chat).filter_by(user_id=user_id)
|
query = db.query(Chat).filter_by(user_id=user_id)
|
||||||
@ -260,9 +260,10 @@ class ChatTable:
|
|||||||
all_chats = (
|
all_chats = (
|
||||||
query.order_by(Chat.updated_at.desc())
|
query.order_by(Chat.updated_at.desc())
|
||||||
# limit cols
|
# limit cols
|
||||||
.with_entities(
|
.with_entities(Chat.id, Chat.title, Chat.updated_at, Chat.created_at)
|
||||||
Chat.id, Chat.title, Chat.updated_at, Chat.created_at
|
.limit(limit)
|
||||||
).all()
|
.offset(skip)
|
||||||
|
.all()
|
||||||
)
|
)
|
||||||
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
|
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
|
||||||
return [
|
return [
|
||||||
|
@ -43,7 +43,7 @@ router = APIRouter()
|
|||||||
@router.get("/", response_model=List[ChatTitleIdResponse])
|
@router.get("/", response_model=List[ChatTitleIdResponse])
|
||||||
@router.get("/list", response_model=List[ChatTitleIdResponse])
|
@router.get("/list", response_model=List[ChatTitleIdResponse])
|
||||||
async def get_session_user_chat_list(
|
async def get_session_user_chat_list(
|
||||||
user=Depends(get_verified_user), skip: int = 0, limit: int = 50
|
user=Depends(get_verified_user), skip: int = 0, limit: int = -1
|
||||||
):
|
):
|
||||||
return Chats.get_chat_title_id_list_by_user_id(user.id, skip=skip, limit=limit)
|
return Chats.get_chat_title_id_list_by_user_id(user.id, skip=skip, limit=limit)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user