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': '二零二三年度报告',