forked from phoenix/litellm-mirror
(feat) proxy add pagination on /user/info endpoint
This commit is contained in:
parent
7d26eaf481
commit
432ce90a9a
2 changed files with 16 additions and 2 deletions
|
@ -4311,6 +4311,14 @@ async def user_info(
|
|||
default=False,
|
||||
description="set to true to View all users. When using view_all, don't pass user_id",
|
||||
),
|
||||
page: int = fastapi.Query(
|
||||
default=1,
|
||||
description="Page number for pagination. Only use when view_all is true",
|
||||
),
|
||||
page_size: int = fastapi.Query(
|
||||
default=10,
|
||||
description="Number of items per page. Only use when view_all is true",
|
||||
),
|
||||
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
|
||||
):
|
||||
"""
|
||||
|
@ -4332,8 +4340,10 @@ async def user_info(
|
|||
if user_id is not None:
|
||||
user_info = await prisma_client.get_data(user_id=user_id)
|
||||
elif view_all == True:
|
||||
offset = (page - 1) * page_size # default is 0
|
||||
limit = page_size # default is 10
|
||||
user_info = await prisma_client.get_data(
|
||||
table_name="user", query_type="find_all"
|
||||
table_name="user", query_type="find_all", offset=offset, limit=limit
|
||||
)
|
||||
return user_info
|
||||
else:
|
||||
|
|
|
@ -613,6 +613,10 @@ class PrismaClient:
|
|||
query_type: Literal["find_unique", "find_all"] = "find_unique",
|
||||
expires: Optional[datetime] = None,
|
||||
reset_at: Optional[datetime] = None,
|
||||
offset: Optional[int] = None, # pagination, what row number to start from
|
||||
limit: Optional[
|
||||
int
|
||||
] = None, # pagination, number of rows to getch when find_all==True
|
||||
):
|
||||
try:
|
||||
response: Any = None
|
||||
|
@ -748,7 +752,7 @@ class PrismaClient:
|
|||
)
|
||||
else:
|
||||
response = await self.db.litellm_usertable.find_many( # type: ignore
|
||||
order={"spend": "desc"},
|
||||
order={"spend": "desc"}, take=limit, skip=offset
|
||||
)
|
||||
return response
|
||||
elif table_name == "spend":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue