From 4d1d1a631db3d30bfcee73ed9dc71a726388d018 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Wed, 6 Dec 2023 21:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B9=B4=E5=BA=A6=E5=88=86=E6=9E=90=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/analysis/analysis.py | 7 +++++++ app/web_ui/web.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/analysis/analysis.py b/app/analysis/analysis.py index 263eb48..56aba51 100644 --- a/app/analysis/analysis.py +++ b/app/analysis/analysis.py @@ -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进行分词,并加入停用词 diff --git a/app/web_ui/web.py b/app/web_ui/web.py index 7ed6d70..5a5c7a6 100644 --- a/app/web_ui/web.py +++ b/app/web_ui/web.py @@ -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': '二零二三年度报告',