修复:平均响应时间排除 handled_at 早于 event_time 的异常数据
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -522,7 +522,7 @@ class AlarmEventService:
|
||||
AlarmEvent.handle_status.in_(["DONE", "IGNORED"])
|
||||
).count()
|
||||
|
||||
# 平均响应时间(从 event_time 到 handled_at,只算已处理的)
|
||||
# 平均响应时间(从 event_time 到 handled_at,只算已处理且时间合理的)
|
||||
from sqlalchemy.sql.expression import literal_column
|
||||
avg_response = db.query(
|
||||
func.avg(
|
||||
@@ -533,7 +533,8 @@ class AlarmEventService:
|
||||
)
|
||||
)
|
||||
).filter(
|
||||
AlarmEvent.handled_at.isnot(None)
|
||||
AlarmEvent.handled_at.isnot(None),
|
||||
AlarmEvent.handled_at > AlarmEvent.event_time,
|
||||
).scalar()
|
||||
|
||||
# 按 alarm_status 计数
|
||||
|
||||
Reference in New Issue
Block a user