mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-05 23:56:36 +08:00
optimize+注释
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 系统状态监控 API:返回爬虫集群运行概况
|
||||
# 系统状态监控 API:返回爬虫集群运行概况(信息源数、今日抓取量、最近同步时间等)
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional
|
||||
|
||||
@@ -28,7 +28,7 @@ def get_system_stats(db: Session = Depends(get_db)):
|
||||
"""获取爬虫集群的当日运行状态。"""
|
||||
today_start = utcnow().replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
|
||||
# 信息源统计
|
||||
# 信息源统计:总数与启用数
|
||||
total_sources = db.query(func.count(InfoSource.id)).scalar() or 0
|
||||
active_sources = (
|
||||
db.query(func.count(InfoSource.id))
|
||||
@@ -36,7 +36,7 @@ def get_system_stats(db: Session = Depends(get_db)):
|
||||
.scalar() or 0
|
||||
)
|
||||
|
||||
# 今日任务统计
|
||||
# 今日任务统计:抓取条数、成功/失败任务数
|
||||
today_tasks = (
|
||||
db.query(DataSyncTask)
|
||||
.filter(DataSyncTask.created_at >= today_start)
|
||||
|
||||
Reference in New Issue
Block a user