修复无聊天数据年度分析报告报错问题#72

This commit is contained in:
shuaikangzhou 2023-12-06 21:59:23 +08:00
parent b6f041b67a
commit 4d1d1a631d
2 changed files with 8 additions and 1 deletions

View File

@ -19,6 +19,13 @@ wordcloud_height = 720
def wordcloud(wxid):
import jieba
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT)
if not txt_messages:
return {
'chart_data': None,
'keyword': "没有聊天你想分析啥",
'max_num': "0",
'dialogs': []
}
text = ''.join(map(lambda x: x[7], txt_messages))
total_msg_len = len(text)
# 使用jieba进行分词并加入停用词

View File

@ -43,7 +43,7 @@ def index0():
def home():
try:
first_message, first_time = msg_db.get_first_time_of_message(contact.wxid)
except IndexError:
except TypeError:
return set_text('咱就是说,一次都没聊过就别分析了')
data = {
'sub_title': '二零二三年度报告',