PATCH: Retrieving last 50 chats now

This commit is contained in:
2025-03-05 22:41:31 +00:00
parent cf798eb984
commit e0f36cfb0e

View File

@@ -76,6 +76,8 @@ def get_past_chat(stream_id: int):
# fetched in format: [(username, message, time_sent, is_subscribed)] # fetched in format: [(username, message, time_sent, is_subscribed)]
all_chats = db.fetchall(""" all_chats = db.fetchall("""
SELECT username, message, time_sent, is_subscribed
FROM (
SELECT SELECT
u.username, u.username,
c.message, c.message,
@@ -89,7 +91,9 @@ def get_past_chat(stream_id: int):
LEFT JOIN subscribes s ON c.chatter_id = s.user_id AND s.subscribed_id = ? LEFT JOIN subscribes s ON c.chatter_id = s.user_id AND s.subscribed_id = ?
WHERE c.stream_id = ? WHERE c.stream_id = ?
ORDER BY c.time_sent DESC ORDER BY c.time_sent DESC
LIMIT 50; LIMIT 50
) subquery
ORDER BY time_sent ASC;
""", (stream_id, stream_id)) """, (stream_id, stream_id))
db.close_connection() db.close_connection()