From 6331c9bf5d0150e0b6d3b317fbc3bc1808ca9c70 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:39:05 -0400 Subject: [PATCH] feat: Support room categories in the channel --- url1/category_n.py | 34 +++++++++++++++++++++------------- url1/category_search.py | 13 ++++++++++--- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/url1/category_n.py b/url1/category_n.py index b10a4f46..115564a3 100644 --- a/url1/category_n.py +++ b/url1/category_n.py @@ -13,24 +13,20 @@ def list_category_n(list_id): results = [] match list_id: case "01": - queried_data = ( - db.session.query(Categories, Rooms) - .filter(Categories.sp_page_id == Rooms.room_id) - .order_by(Categories.name.asc()) - .limit(64) - .all() + queried_categories = ( + Categories.query.order_by(Categories.name.asc()).limit(64).all() ) - for i, category in enumerate(queried_data): + for i, category in enumerate(queried_categories): # Items must be indexed by 1. results.append( RepeatedElement( { "place": i + 1, - "categid": category[0].category_id, - "name": category[0].name, - "sppageid": category[1].room_id, - "splinktext": category[1].news, + "categid": category.category_id, + "name": category.name, + "sppageid": 0, + "splinktext": "Link text", } ) ) @@ -57,8 +53,20 @@ def list_category_n(list_id): ) ) case "03": - # TODO: Rooms - pass + queried_data = Rooms.query.order_by(Rooms.news.asc()).all() + for i, room in enumerate(queried_data): + # Items must be indexed by 1. + results.append( + RepeatedElement( + { + "place": i + 1, + "categid": 30000 + room.room_id, + "name": room.news, + "sppageid": room.room_id, + "splinktext": room.news, + } + ) + ) return { "type": 3, diff --git a/url1/category_search.py b/url1/category_search.py index d0ebecdf..cfd3f9d1 100644 --- a/url1/category_search.py +++ b/url1/category_search.py @@ -1,6 +1,6 @@ from werkzeug import exceptions -from models import Movies, ConciergeMovies +from models import Movies, ConciergeMovies, Rooms from room import app from helpers import xml_node_name, RepeatedElement, current_date_and_time @@ -12,6 +12,7 @@ def list_category_search(categ_id): retrieved_data = ( Movies.query.filter(Movies.category_id == categ_id) .order_by(Movies.date_added.desc()) + .limit(100) .all() ) elif 20000 <= categ_id <= 29999: @@ -20,11 +21,17 @@ def list_category_search(categ_id): Movies.query.filter(Movies.movie_id == ConciergeMovies.movie_id) .filter(ConciergeMovies.mii_id == categ_id - 20000) .order_by(Movies.date_added.desc()) + .limit(100) .all() ) else: - # TODO: This will be rooms - retrieved_data = None + retrieved_data = ( + Movies.query.filter(Movies.sp_page_id == Rooms.room_id) + .filter(Rooms.room_id == categ_id - 30000) + .order_by(Movies.date_added.desc()) + .limit(100) + .all() + ) results = []