|
@@ -182,11 +182,15 @@ class MySQLSessionManager(SessionManager):
|
|
|
temp_obj = {}
|
|
|
user_id = session["user_id"]
|
|
|
room_id = ":".join(["private", staff_id, user_id])
|
|
|
- select_query = f"""select content, msg_type, max(sendtime) as max_timestamp from {self.chat_history_table} where roomid = %s;"""
|
|
|
+ select_query = f"""
|
|
|
+ select content, msg_type, sendtime as max_timestamp
|
|
|
+ from {self.chat_history_table} where roomid = %s
|
|
|
+ order by sendtime desc limit %s;
|
|
|
+ """
|
|
|
last_message = self.db.select(
|
|
|
sql=select_query,
|
|
|
cursor_type=pymysql.cursors.DictCursor,
|
|
|
- args=(room_id,),
|
|
|
+ args=(room_id, 1),
|
|
|
)
|
|
|
if not last_message:
|
|
|
temp_obj["message"] = None
|