mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
fix SiteStatistic
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
"name": "站点数据统计",
|
||||
"description": "站点统计数据图表。",
|
||||
"labels": "站点,仪表板",
|
||||
"version": "1.7.2",
|
||||
"version": "1.8",
|
||||
"icon": "statistic.png",
|
||||
"author": "lightolly,jxxghp",
|
||||
"level": 2,
|
||||
"history": {
|
||||
"v1.7.2": "修复站点数据增量处理逻辑",
|
||||
"v1.8": "修复站点数据增量处理逻辑",
|
||||
"v1.7.1": "优化内存占用",
|
||||
"v1.6": "优化了站点数据获取失败时的回退逻辑",
|
||||
"v1.5": "修复了发送增量通知失败等一些问题",
|
||||
|
||||
@@ -32,7 +32,7 @@ class SiteStatistic(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "statistic.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.7.2"
|
||||
plugin_version = "1.8"
|
||||
# 插件作者
|
||||
plugin_author = "lightolly,jxxghp"
|
||||
# 作者主页
|
||||
@@ -232,8 +232,16 @@ class SiteStatistic(_PluginBase):
|
||||
if self._notify_type == "inc":
|
||||
# 增量数据模式:只有当有昨天数据时才计算增量
|
||||
if yesterday_data_dict.get(site):
|
||||
upload -= int(yesterday_data_dict[site].upload or 0)
|
||||
download -= int(yesterday_data_dict[site].download or 0)
|
||||
yesterday_upload = int(yesterday_data_dict[site].upload or 0)
|
||||
yesterday_download = int(yesterday_data_dict[site].download or 0)
|
||||
|
||||
# 如果昨天上传和下载数据为0,则跳过该站点
|
||||
# 因为昨天数据为0时,计算出来的是累计数据而非增量
|
||||
if not yesterday_upload and not yesterday_download:
|
||||
continue
|
||||
|
||||
upload -= yesterday_upload
|
||||
download -= yesterday_download
|
||||
# 确保增量不为负数
|
||||
upload = max(0, upload)
|
||||
download = max(0, download)
|
||||
@@ -364,6 +372,16 @@ class SiteStatistic(_PluginBase):
|
||||
if not d2:
|
||||
# 如果没有昨天数据,返回空字典,表示无增量数据
|
||||
return {}
|
||||
|
||||
# 检查昨天的关键数据是否为0,如果是则不计算增量
|
||||
# 因为昨天数据为0时,计算出来的是累计数据而非增量
|
||||
for key in ['upload', 'download']:
|
||||
if key in d2:
|
||||
yesterday_value = __to_numeric(d2.get(key))
|
||||
# 如果昨天数据为0,不计算增量
|
||||
if yesterday_value == 0:
|
||||
return {}
|
||||
|
||||
d = {k: __to_numeric(d1.get(k)) - __to_numeric(d2.get(k)) for k in d1
|
||||
if k in d2 and __is_digit(d1.get(k)) and __is_digit(d2.get(k))}
|
||||
# 把小于0的数据变成0
|
||||
|
||||
Reference in New Issue
Block a user