From 7ba44f92e356631c8746ec845ec1b61806c6048d Mon Sep 17 00:00:00 2001 From: SiYuan <863909694@qq.com> Date: Fri, 9 Feb 2024 17:14:09 +0800 Subject: [PATCH] update readme.md --- app/DataBase/msg.py | 48 ++++++++++++++++++++++++++++++++ app/analysis/analysis.py | 7 +++-- app/ui/chat/ai_chat.py | 12 ++++++-- app/web_ui/templates/index.html | 4 +-- app/web_ui/web.py | 3 +- doc/images/why.gif | Bin 0 -> 350324 bytes doc/images/病假.gif | Bin 0 -> 131191 bytes readme.md | 4 +++ 8 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 doc/images/why.gif create mode 100644 doc/images/病假.gif diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index 304f80c..70f28cf 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -785,7 +785,55 @@ class Msg: finally: lock.release() return result + def get_message_length( + self, + username_='', + time_range: Tuple[int | float | str | date, int | float | str | date] = None, + )->int: + """ + 统计自己总共发消息的字数,包含type=1的文本和type=49,subtype=57里面自己发的文本 + """ + if time_range: + start_time, end_time = convert_to_timestamp(time_range) + sql_type_1 = f""" + SELECT sum(length(strContent)) + from MSG + where StrTalker = ? and + type = 1 + {'AND CreateTime>' + str(start_time) + ' AND CreateTime<' + str(end_time) if time_range else ''} + """ + sql_type_49 = f""" + SELECT CompressContent + from MSG + where StrTalker = ? and + type = 49 and subtype = 57 + {'AND CreateTime>' + str(start_time) + ' AND CreateTime<' + str(end_time) if time_range else ''} + """ + sum_type_1 = 0 + result_type_1 = 0 + result_type_49 = 0 + sum_type_49 = 0 + if not self.open_flag: + return None + try: + lock.acquire(True) + self.cursor.execute(sql_type_1,[username_]) + result_type_1 = self.cursor.fetchall()[0][0] + self.cursor.execute(sql_type_49,[username_]) + result_type_49 = self.cursor.fetchall() + except sqlite3.DatabaseError: + logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试') + finally: + lock.release() + for message in result_type_49: + message = message[0] + content = parser_reply(message) + if content["is_error"]: + continue + sum_type_49 += len(content["title"]) + sum_type_1 = result_type_1 if result_type_1 else 0 + return sum_type_1 + sum_type_49 def close(self): if self.open_flag: try: diff --git a/app/analysis/analysis.py b/app/analysis/analysis.py index f6d1a79..b6b4121 100644 --- a/app/analysis/analysis.py +++ b/app/analysis/analysis.py @@ -94,7 +94,10 @@ def get_wordcloud(text): text_data = data[:100] if len(data) > 100 else data # 创建词云图 - keyword, max_num = text_data[0] + if text_data: + keyword, max_num = text_data[0] + else: + keyword, max_num = '', 0 w = ( WordCloud() .add(series_name="聊天文字", data_pair=text_data, word_size_range=[5, 40]) @@ -483,7 +486,7 @@ def my_message_counter(time_range, my_name=''): 'chart_data_wordcloud': w.get('chart_data_wordcloud'), 'keyword': w.get('keyword'), 'keyword_max_num': w.get('keyword_max_num'), - 'total_text_num':total_text_num, + 'total_text_num': total_text_num, } diff --git a/app/ui/chat/ai_chat.py b/app/ui/chat/ai_chat.py index 32c77ec..79650fb 100644 --- a/app/ui/chat/ai_chat.py +++ b/app/ui/chat/ai_chat.py @@ -14,9 +14,8 @@ try: from .chatInfoUi import Ui_Form except: from chatInfoUi import Ui_Form -from app.DataBase import msg_db, hard_link_db -from app.components.bubble_message import BubbleMessage, ChatWidget, Notice -from app.person import Me, Contact, ContactDefault +from app.components.bubble_message import BubbleMessage +from app.person import Me,ContactDefault class Message(QWidget): @@ -145,7 +144,14 @@ class AIChatThread(QThread): } ] } + message = ''' + 幼儿园三班一共有35人,上个月34人满勤。\n其中1月15日,小明同学感冒了,他的妈妈给他请了一天的病假。 + ''' try: + # for s in message: + # self.msgSignal.emit(s) + # time.sleep(0.05) + # return resp = requests.post(url, json=data, stream=True) if resp.status_code == 200: for line in resp.iter_lines(): diff --git a/app/web_ui/templates/index.html b/app/web_ui/templates/index.html index f58d500..9aa79cd 100644 --- a/app/web_ui/templates/index.html +++ b/app/web_ui/templates/index.html @@ -324,14 +324,14 @@ p {

年度聊天好友

聊天榜单