mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-24 23:29:40 +00:00
🐛 Fix ZeroDivisionError in action log
This commit is contained in:
parent
bd9785b6f6
commit
87c22d56fb
@ -60,11 +60,13 @@ class ActionLogAnalyse(DateUtils):
|
|||||||
|
|
||||||
def get_this_month_avg_duration(self) -> float:
|
def get_this_month_avg_duration(self) -> float:
|
||||||
"""本月平均时长"""
|
"""本月平均时长"""
|
||||||
return self.get_this_month_duration() / len(self.this_month_data)
|
data_len = len(self.this_month_data)
|
||||||
|
return (self.get_this_month_duration() / data_len) if data_len else 0
|
||||||
|
|
||||||
def get_last_month_avg_duration(self) -> float:
|
def get_last_month_avg_duration(self) -> float:
|
||||||
"""上月平均时长"""
|
"""上月平均时长"""
|
||||||
return self.get_last_month_duration() / len(self.last_month_data)
|
data_len = len(self.last_month_data)
|
||||||
|
return (self.get_last_month_duration() / data_len) if data_len else 0
|
||||||
|
|
||||||
def get_this_week_long_duration(self) -> int:
|
def get_this_week_long_duration(self) -> int:
|
||||||
"""周最长会话"""
|
"""周最长会话"""
|
||||||
|
@ -80,7 +80,7 @@ class ActionLogPlugins(Plugin):
|
|||||||
self.add_delete_message_job(msg, delay=60)
|
self.add_delete_message_job(msg, delay=60)
|
||||||
|
|
||||||
async def get_render_data(self, uid: int):
|
async def get_render_data(self, uid: int):
|
||||||
r = await self.action_log_service.get_data(uid, 1)
|
r = await self.action_log_service.get_data(uid, 63)
|
||||||
r2 = await self.action_log_service.count_uptime_period(uid)
|
r2 = await self.action_log_service.count_uptime_period(uid)
|
||||||
if not r or not r2:
|
if not r or not r2:
|
||||||
raise NotSupport("未查询到登录记录")
|
raise NotSupport("未查询到登录记录")
|
||||||
|
Loading…
Reference in New Issue
Block a user