FIX: Followed Categories
This commit is contained in:
@@ -126,6 +126,18 @@ def following_categories_streams():
|
||||
return jsonify(streams)
|
||||
|
||||
|
||||
@login_required
|
||||
@stream_bp.route('/categories/your_categories')
|
||||
def following_your_categories():
|
||||
"""
|
||||
Returns categories which the user followed
|
||||
"""
|
||||
|
||||
streams = get_followed_your_categories(session.get('user_id'))
|
||||
return jsonify(streams)
|
||||
|
||||
|
||||
|
||||
# User Routes
|
||||
@stream_bp.route('/user/<string:username>/status')
|
||||
def user_live_status(username):
|
||||
|
||||
@@ -107,28 +107,28 @@ INSERT INTO streams (user_id, title, start_time, category_id) VALUES
|
||||
(3, 'Sketching Live', '2025-01-24 15:00:00', 3),
|
||||
(4, 'Math Made Easy', '2025-01-23 10:00:00', 4),
|
||||
(5, 'Sports Highlights', '2025-02-15 23:00:00', 5),
|
||||
(6, 'Genshin1', '2025-02-17 18:00:00', 22),
|
||||
(7, 'Genshin2', '2025-02-18 19:00:00', 22),
|
||||
(8, 'Genshin3', '2025-02-19 20:00:00', 22),
|
||||
(9, 'Genshin4', '2025-02-20 14:00:00', 22),
|
||||
(10, 'Genshin5', '2025-02-21 09:00:00', 22),
|
||||
(11, 'Genshin6', '2025-02-22 11:00:00', 22),
|
||||
(12, 'Genshin7', '2025-02-23 21:00:00', 22),
|
||||
(13, 'Genshin8', '2025-02-24 16:00:00', 22),
|
||||
(14, 'Genshin9', '2025-02-25 22:00:00', 22),
|
||||
(15, 'Genshin10', '2025-02-26 18:30:00', 22),
|
||||
(16, 'Genshin11', '2025-02-27 17:00:00', 22),
|
||||
(17, 'Genshin12', '2025-02-28 15:00:00', 22),
|
||||
(18, 'Genshin13', '2025-03-01 10:00:00', 22),
|
||||
(19, 'Genshin14', '2025-03-02 20:00:00', 22),
|
||||
(20, 'Genshin15', '2025-03-03 13:00:00', 22),
|
||||
(21, 'Genshin16', '2025-03-04 09:00:00', 22),
|
||||
(6, 'Genshin1', '2025-02-17 18:00:00', 6),
|
||||
(7, 'Genshin2', '2025-02-18 19:00:00', 7),
|
||||
(8, 'Genshin3', '2025-02-19 20:00:00', 8),
|
||||
(9, 'Genshin4', '2025-02-20 14:00:00', 9),
|
||||
(10, 'Genshin5', '2025-02-21 09:00:00', 10),
|
||||
(11, 'Genshin6', '2025-02-22 11:00:00', 11),
|
||||
(12, 'Genshin7', '2025-02-23 21:00:00', 12),
|
||||
(13, 'Genshin8', '2025-02-24 16:00:00', 13),
|
||||
(14, 'Genshin9', '2025-02-25 22:00:00', 14),
|
||||
(15, 'Genshin10', '2025-02-26 18:30:00', 15),
|
||||
(16, 'Genshin11', '2025-02-27 17:00:00', 16),
|
||||
(17, 'Genshin12', '2025-02-28 15:00:00', 17),
|
||||
(18, 'Genshin13', '2025-03-01 10:00:00', 18),
|
||||
(19, 'Genshin14', '2025-03-02 20:00:00', 19),
|
||||
(20, 'Genshin15', '2025-03-03 13:00:00', 20),
|
||||
(21, 'Genshin16', '2025-03-04 09:00:00', 21),
|
||||
(22, 'Genshin17', '2025-03-05 12:00:00', 22),
|
||||
(23, 'Genshin18', '2025-03-06 14:00:00', 22),
|
||||
(24, 'Genshin19', '2025-03-07 16:00:00', 22),
|
||||
(25, 'Genshin20', '2025-03-08 19:00:00', 22),
|
||||
(26, 'Genshin21', '2025-03-09 21:00:00', 22),
|
||||
(27, 'Genshin22', '2025-03-10 17:00:00', 11);
|
||||
(23, 'Genshin18', '2025-03-06 14:00:00', 23),
|
||||
(24, 'Genshin19', '2025-03-07 16:00:00', 24),
|
||||
(25, 'Genshin20', '2025-03-08 19:00:00', 25),
|
||||
(26, 'Genshin21', '2025-03-09 21:00:00', 26),
|
||||
(27, 'Genshin22', '2025-03-10 17:00:00', 27);
|
||||
|
||||
-- Sample Data for vods
|
||||
INSERT INTO vods (user_id, title, datetime, category_id, length, views) VALUES
|
||||
|
||||
@@ -33,6 +33,20 @@ def get_followed_categories_recommendations(user_id: int, no_streams: int = 4) -
|
||||
""", (user_id, no_streams))
|
||||
return streams
|
||||
|
||||
def get_followed_your_categories(user_id: int) -> Optional[List[dict]]:
|
||||
"""
|
||||
Returns all user followed categories
|
||||
"""
|
||||
with Database() as db:
|
||||
categories = db.fetchall("""
|
||||
SELECT categories.category_name
|
||||
FROM categories
|
||||
JOIN followed_categories
|
||||
ON categories.category_id = followed_categories.category_id
|
||||
WHERE followed_categories.user_id = ?;
|
||||
""", (user_id,))
|
||||
return categories
|
||||
|
||||
|
||||
def get_streams_based_on_category(category_id: int, no_streams: int = 4, offset: int = 0) -> Optional[List[dict]]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user