mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 13:48:19 +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:
|
||||
"""本月平均时长"""
|
||||
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:
|
||||
"""上月平均时长"""
|
||||
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:
|
||||
"""周最长会话"""
|
||||
|
@ -80,7 +80,7 @@ class ActionLogPlugins(Plugin):
|
||||
self.add_delete_message_job(msg, delay=60)
|
||||
|
||||
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)
|
||||
if not r or not r2:
|
||||
raise NotSupport("未查询到登录记录")
|
||||
|
Loading…
Reference in New Issue
Block a user