|
@@ -183,14 +183,15 @@ class MySQLSessionManager(SessionManager):
|
|
|
user_id = session["user_id"]
|
|
|
room_id = ":".join(["private", staff_id, user_id])
|
|
|
select_query = f"""
|
|
|
- select content, max(sendtime) as max_timestamp, msg_type
|
|
|
+ select content, sendtime as max_timestamp, msg_type
|
|
|
from {self.chat_history_table}
|
|
|
- where roomid = %s;
|
|
|
+ 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
|