From b6ccd18fac5702bbdfce0c840a01315fe9617f96 Mon Sep 17 00:00:00 2001 From: JustIceO7 Date: Thu, 6 Feb 2025 13:43:52 +0000 Subject: [PATCH] FEAT: Made categories return the total number of viewers watching the category --- frontend/src/context/StreamsContext.tsx | 2 +- web_server/utils/recommendation_utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/context/StreamsContext.tsx b/frontend/src/context/StreamsContext.tsx index 2b0f721..0fdff33 100644 --- a/frontend/src/context/StreamsContext.tsx +++ b/frontend/src/context/StreamsContext.tsx @@ -34,7 +34,7 @@ export function StreamsProvider({ children }: { children: React.ReactNode }) { const { isLoggedIn } = useAuth(); 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"]; useEffect(() => { diff --git a/web_server/utils/recommendation_utils.py b/web_server/utils/recommendation_utils.py index 4f79d28..142450e 100644 --- a/web_server/utils/recommendation_utils.py +++ b/web_server/utils/recommendation_utils.py @@ -72,7 +72,7 @@ def get_highest_view_categories(no_categories: int) -> Optional[List[dict]]: """ with Database() as db: 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 JOIN categories ON streams.category_id = categories.category_id GROUP BY categories.category_name