refactor(database): 优化数据库关联对象的载入 (#10)
This commit is contained in:
@@ -28,19 +28,10 @@ async def get_users(
|
||||
):
|
||||
if user_ids:
|
||||
searched_users = (
|
||||
await session.exec(
|
||||
select(User)
|
||||
.options(*User.all_select_option())
|
||||
.limit(50)
|
||||
.where(col(User.id).in_(user_ids))
|
||||
)
|
||||
await session.exec(select(User).limit(50).where(col(User.id).in_(user_ids)))
|
||||
).all()
|
||||
else:
|
||||
searched_users = (
|
||||
await session.exec(
|
||||
select(User).options(*User.all_select_option()).limit(50)
|
||||
)
|
||||
).all()
|
||||
searched_users = (await session.exec(select(User).limit(50))).all()
|
||||
return BatchUserResponse(
|
||||
users=[
|
||||
await UserResp.from_db(
|
||||
@@ -63,9 +54,7 @@ async def get_user_info(
|
||||
):
|
||||
searched_user = (
|
||||
await session.exec(
|
||||
select(User)
|
||||
.options(*User.all_select_option())
|
||||
.where(
|
||||
select(User).where(
|
||||
User.id == int(user)
|
||||
if user.isdigit()
|
||||
else User.username == user.removeprefix("@")
|
||||
|
||||
Reference in New Issue
Block a user