From 595195dedc8841d98e93df77c664eb354f420226 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Mon, 10 Mar 2025 20:31:01 +0800 Subject: [PATCH] update --- app/api/endpoints/community.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/api/endpoints/community.py b/app/api/endpoints/community.py index 5cbaf4f..2fb5cac 100644 --- a/app/api/endpoints/community.py +++ b/app/api/endpoints/community.py @@ -77,10 +77,7 @@ async def get_communities( if status: query = query.filter(CommunityDB.status == status) - # 获取总数(使用子查询优化计数操作) - from sqlalchemy import func - count_query = query.statement.with_only_columns([func.count()]).order_by(None) - total = db.execute(count_query).scalar() + total = query.count() # 查询数据 communities = query.offset(skip).limit(limit).all()