From afb329934a3e89ec6769458e07ea7dfc65a70014 Mon Sep 17 00:00:00 2001 From: fawney19 Date: Thu, 25 Dec 2025 19:54:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AB=AF=E7=82=B9?= =?UTF-8?q?=E5=81=A5=E5=BA=B7=E7=BB=9F=E8=AE=A1=E6=97=B6=E9=97=B4=E5=88=86?= =?UTF-8?q?=E6=AE=B5=E8=AE=A1=E7=AE=97=E7=9A=84=E9=99=A4=E9=9B=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/health/endpoint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/health/endpoint.py b/src/services/health/endpoint.py index fcca602..0e51a69 100644 --- a/src/services/health/endpoint.py +++ b/src/services/health/endpoint.py @@ -234,8 +234,8 @@ class EndpointHealthService: for api_format in format_key_mapping.keys() } - # 计算时间范围 - interval_minutes = (lookback_hours * 60) // segments + # 计算时间范围(使用秒级精度避免整除导致的除零错误) + segment_seconds = (lookback_hours * 3600) / segments start_time = now - timedelta(hours=lookback_hours) # 使用 RequestCandidate 表查询所有尝试记录 @@ -243,7 +243,7 @@ class EndpointHealthService: final_statuses = ["success", "failed", "skipped"] segment_expr = func.floor( - func.extract('epoch', RequestCandidate.created_at - start_time) / (interval_minutes * 60) + func.extract('epoch', RequestCandidate.created_at - start_time) / segment_seconds ).label('segment_idx') candidate_stats = (