BUG: /categories/recommended
This commit is contained in:
@@ -9,7 +9,7 @@ import { getCategoryThumbnail } from "../utils/thumbnailUtils";
|
|||||||
|
|
||||||
// Process API data into our VodType structure
|
// Process API data into our VodType structure
|
||||||
const processVodData = (data: any[]): VodType[] => {
|
const processVodData = (data: any[]): VodType[] => {
|
||||||
console.log("Raw API VOD Data:", data); // Debugging
|
|
||||||
return data.map((vod) => ({
|
return data.map((vod) => ({
|
||||||
type: "vod",
|
type: "vod",
|
||||||
id: vod.id, // Ensure this matches API response
|
id: vod.id, // Ensure this matches API response
|
||||||
@@ -40,6 +40,7 @@ const processStreamData = (data: any[]): StreamType[] => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const processCategoryData = (data: any[]): CategoryType[] => {
|
const processCategoryData = (data: any[]): CategoryType[] => {
|
||||||
|
console.log("Raw API VOD Data:", data); // Debugging
|
||||||
return data.map((category) => ({
|
return data.map((category) => ({
|
||||||
type: "category",
|
type: "category",
|
||||||
id: category.category_id,
|
id: category.category_id,
|
||||||
@@ -135,6 +136,9 @@ export function useCategories(customUrl?: string): {
|
|||||||
[isLoggedIn, customUrl]
|
[isLoggedIn, customUrl]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("Fetched Cat Data:", data); // Debugging
|
||||||
|
|
||||||
|
|
||||||
return { categories: data, isLoading, error };
|
return { categories: data, isLoading, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +154,6 @@ export function useVods(customUrl?: string): {
|
|||||||
[customUrl]
|
[customUrl]
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Fetched VODs Data:", data); // Debugging
|
|
||||||
|
|
||||||
return { vods: data, isLoading, error };
|
return { vods: data, isLoading, error };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ def recommended_streams() -> list[dict]:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
user_id = session.get("user_id")
|
user_id = session.get("user_id")
|
||||||
|
|
||||||
# Get the user's most popular categories
|
# Get the user's most popular categories
|
||||||
category = get_user_preferred_category(user_id)
|
category = get_user_preferred_category(user_id)
|
||||||
streams = get_streams_based_on_category(category)
|
streams = get_streams_based_on_category(category)
|
||||||
@@ -112,7 +111,7 @@ def recommended_categories() -> list | list[dict]:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
user_id = session.get("user_id")
|
user_id = session.get("user_id")
|
||||||
categories = get_user_category_recommendations(user_id)
|
categories = get_user_category_recommendations(1)
|
||||||
return jsonify(categories)
|
return jsonify(categories)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ def get_highest_view_categories(no_categories: int = 4, offset: int = 0) -> Opti
|
|||||||
""", (no_categories, offset))
|
""", (no_categories, offset))
|
||||||
return categories
|
return categories
|
||||||
|
|
||||||
def get_user_category_recommendations(user_id: int, no_categories: int = 4) -> Optional[List[dict]]:
|
def get_user_category_recommendations(user_id: 1, no_categories: int = 4) -> Optional[List[dict]]:
|
||||||
"""
|
"""
|
||||||
Queries user_preferences database to find users top favourite streaming category and returns the category
|
Queries user_preferences database to find users top favourite streaming category and returns the category
|
||||||
"""
|
"""
|
||||||
@@ -90,8 +90,8 @@ def get_user_category_recommendations(user_id: int, no_categories: int = 4) -> O
|
|||||||
SELECT categories.category_id, categories.category_name
|
SELECT categories.category_id, categories.category_name
|
||||||
FROM categories
|
FROM categories
|
||||||
JOIN user_preferences ON categories.category_id = user_preferences.category_id
|
JOIN user_preferences ON categories.category_id = user_preferences.category_id
|
||||||
WHERE user_id = ?
|
WHERE user_preferences.user_id = ?
|
||||||
ORDER BY favourability DESC
|
ORDER BY user_preferences.favourability DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
""", (user_id, no_categories))
|
""", (user_id, no_categories))
|
||||||
return categories
|
return categories
|
||||||
Reference in New Issue
Block a user