UPDATE: Added util functions for handling streaming routes

This commit is contained in:
JustIceO7
2025-01-29 03:04:56 +00:00
parent 46c7ca3f10
commit 95827ccf95
3 changed files with 70 additions and 12 deletions

View File

@@ -16,4 +16,24 @@ def tags():
db = Database()
cursor = db.create_connection()
all_tags = cursor.execute("SELECT * FROM tags").fetchall()
return all_tags
return all_tags
def most_popular_category():
"""
Returns the most popular category based on live stream viewers
"""
db = Database()
cursor = db.create_connection()
category = cursor.execute("""
SELECT categories.category_id, categories.category_name
FROM streams
JOIN categories ON streams.category_id = categories.category_id
WHERE streams.isLive = 1
GROUP BY categories.category_name
ORDER BY SUM(streams.num_viewers) DESC
LIMIT 1;
""").fetchone()
return category