From f6754c0db8561620bfa073fb1c8d3a08c9a41ef2 Mon Sep 17 00:00:00 2001 From: CoderKang Date: Wed, 6 Dec 2023 23:54:12 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/msg.py | 28 +++++++++++++++++++++++----- app/components/bubble_message.py | 2 ++ app/ui_pc/chat/chat_info.py | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a6bdc7e..580d6e8 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -58,7 +58,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? + where TRIM(StrTalker)=? order by CreateTime ''' try: @@ -87,11 +87,29 @@ class Msg: result.sort(key=lambda x: x[5]) return result + def get_messages_length(self): + sql = ''' + select count(*) + from MSG + ''' + if not self.open_flag: + return None + try: + lock.acquire(True) + self.cursor.execute(sql) + result = self.cursor.fetchone() + except Exception as e: + result = None + finally: + lock.release() + return result[0] + + def get_message_by_num(self, username_, local_id): sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime from MSG - where StrTalker = ? and localId < ? + where TRIM(StrTalker) = ? and localId < ? order by CreateTime desc limit 10 ''' @@ -115,7 +133,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? and Type=? + where TRIM(StrTalker)=? and Type=? order by CreateTime ''' try: @@ -132,7 +150,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? and Type=1 and LENGTH(StrContent) None: