FEAT: Made categories return the total number of viewers watching the category

This commit is contained in:
JustIceO7
2025-02-06 13:43:52 +00:00
parent a6f49e8f66
commit b6ccd18fac
2 changed files with 2 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ export function StreamsProvider({ children }: { children: React.ReactNode }) {
const { isLoggedIn } = useAuth(); const { isLoggedIn } = useAuth();
const fetch_url = isLoggedIn const fetch_url = isLoggedIn
? ["/api/get_recommended_streams", "/api/get_followed_category_streams"] ? ["/api/streams/recommended", "/api/categories/following"]
: ["/api/streams/popular/4", "/api/categories/popular/4"]; : ["/api/streams/popular/4", "/api/categories/popular/4"];
useEffect(() => { useEffect(() => {

View File

@@ -72,7 +72,7 @@ def get_highest_view_categories(no_categories: int) -> Optional[List[dict]]:
""" """
with Database() as db: with Database() as db:
categories = db.fetchall(""" categories = db.fetchall("""
SELECT categories.category_id, categories.category_name, SUM(streams.num_viewers) AS total_viewers SELECT categories.category_id, categories.category_name, SUM(streams.num_viewers) AS num_viewers
FROM streams FROM streams
JOIN categories ON streams.category_id = categories.category_id JOIN categories ON streams.category_id = categories.category_id
GROUP BY categories.category_name GROUP BY categories.category_name