FEAT: Made categories return the total number of viewers watching the category
This commit is contained in:
@@ -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(() => {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user