UPDATE: Fix to stream/userpage routing, Added UserPage and Tidy to code;

Added ability to visit a user's profile page from their stream;
Cleaned up code formatting, primarily changing from single quotes to double quotes;
Removed unused SignupForm component;
This commit is contained in:
Chris-1010
2025-02-04 14:59:18 +00:00
parent f31834bc1d
commit 60c19b3052
24 changed files with 325 additions and 150 deletions

View File

@@ -1,6 +1,7 @@
from database.database import Database
from typing import Optional, List
def user_recommendation_category(user_id: int) -> Optional[int]:
"""
Queries user_preferences database to find users favourite streaming category and returns the category
@@ -15,7 +16,8 @@ def user_recommendation_category(user_id: int) -> Optional[int]:
""", (user_id,))
return category["category_id"] if category else None
def followed_categories_recommendations(user_id : int) -> Optional[List[dict]]:
def followed_categories_recommendations(user_id: int) -> Optional[List[dict]]:
"""
Returns top 25 streams given a users category following
"""
@@ -31,6 +33,7 @@ def followed_categories_recommendations(user_id : int) -> Optional[List[dict]]:
""", (user_id,))
return streams
def recommendations_based_on_category(category_id: int) -> Optional[List[dict]]:
"""
Queries stream database to get top 25 most viewed streams based on given category
@@ -58,11 +61,13 @@ def default_recommendations() -> Optional[List[dict]]:
FROM streams
JOIN users ON users.user_id = streams.user_id
JOIN categories ON streams.category_id = categories.category_id
WHERE isLive = 1
ORDER BY num_viewers DESC
LIMIT 25;
""")
return data
def category_recommendations() -> Optional[List[dict]]:
"""
Returns a list of the top 5 most popular live categories
@@ -79,6 +84,7 @@ def category_recommendations() -> Optional[List[dict]]:
""")
return categories
def user_category_recommendations(user_id: int) -> Optional[List[dict]]:
"""
Queries user_preferences database to find users top 5 favourite streaming category and returns the category
@@ -92,4 +98,4 @@ def user_category_recommendations(user_id: int) -> Optional[List[dict]]:
ORDER BY favourability DESC
LIMIT 5
""", (user_id,))
return categories
return categories