From 92bc6ab8d67ae95c43dfb8f59c71719a691da964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Wed, 8 Apr 2026 13:13:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E5=AF=BB=E9=85=8D?= =?UTF-8?q?=E5=8F=B7=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/information.py | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index f981a63..ae3648e 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -1078,26 +1078,41 @@ def get_seek_stats( db: Session = Depends(get_db) ): """获取寻配号统计数据""" - # 寻号需求数(seek类型总数) + from sqlalchemy import or_, and_ + + # 寻号需求数(seek类型且expect_number不为空的总数) seek_count = db.query(Information).filter( - Information.info_type == 'seek' + Information.info_type == 'seek', + Information.expect_number.isnot(None), + Information.expect_number != '' ).count() - # 我的藏品匹配成功数(is_matched = 'confirmed'且有matched_user_id) + # 我的匹配:自有藏品匹配成功的寻号帖子数量(is_matched为confirmed或pending_network) user_matched_count = 0 if current_user: user_matched_count = db.query(Information).filter( Information.info_type == 'seek', - Information.is_matched == 'confirmed', - Information.matched_user_id == current_user.f99_90_id + Information.expect_number.isnot(None), + Information.expect_number != '', + Information.matched_user_id == current_user.f99_90_id, + Information.is_matched != 'pending' ).count() - # 总共匹配成功数(包含我的藏品匹配+网络数据匹配成功的) - # 网络数据匹配成功的定义:is_matched = 'confirmed' - total_matched_count = db.query(Information).filter( + # 总共匹配 = 自有匹配成功数 + 网络数据匹配成功数 + # 自有匹配成功:is_matched = 'confirmed' + # 网络数据匹配成功:is_matched = 'pending_network'(表示网络数据已匹配) + from sqlalchemy import func + self_matched = db.query(func.count(Information.f99_90_id)).filter( Information.info_type == 'seek', Information.is_matched == 'confirmed' - ).count() + ).scalar() or 0 + + network_matched = db.query(func.count(Information.f99_90_id)).filter( + Information.info_type == 'seek', + Information.is_matched == 'pending_network' + ).scalar() or 0 + + total_matched_count = self_matched + network_matched return { "seekCount": seek_count,