Merge pull request #1300 from Cookie987/dev

提升统计任务容错性(Fix #1288)
pull/1318/head
SengokuCola 2025-10-25 16:02:56 +08:00 committed by GitHub
commit ccfd6cc02d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 22 deletions

View File

@ -519,6 +519,7 @@ class StatisticOutputTask(AsyncTask):
last_all_time_stat = None last_all_time_stat = None
try:
if "last_full_statistics" in local_storage: if "last_full_statistics" in local_storage:
# 如果存在上次完整统计数据,则使用该数据进行增量统计 # 如果存在上次完整统计数据,则使用该数据进行增量统计
last_stat: Dict[str, Any] = local_storage["last_full_statistics"] # 上次完整统计数据 # type: ignore last_stat: Dict[str, Any] = local_storage["last_full_statistics"] # 上次完整统计数据 # type: ignore
@ -542,6 +543,8 @@ class StatisticOutputTask(AsyncTask):
last_stat_timestamp = datetime.fromtimestamp(last_stat["timestamp"]) # 上次完整统计数据的时间戳 last_stat_timestamp = datetime.fromtimestamp(last_stat["timestamp"]) # 上次完整统计数据的时间戳
self.stat_period = [item for item in self.stat_period if item[0] != "all_time"] # 删除"所有时间"的统计时段 self.stat_period = [item for item in self.stat_period if item[0] != "all_time"] # 删除"所有时间"的统计时段
self.stat_period.append(("all_time", now - last_stat_timestamp, "自部署以来的")) self.stat_period.append(("all_time", now - last_stat_timestamp, "自部署以来的"))
except Exception as e:
logger.warning(f"加载上次完整统计数据失败,进行全量统计,错误信息:{e}")
stat_start_timestamp = [(period[0], now - period[1]) for period in self.stat_period] stat_start_timestamp = [(period[0], now - period[1]) for period in self.stat_period]