Skip to content

Commit

Permalink
feat: Support room categories in the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jul 1, 2024
1 parent 239410d commit 6331c9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
34 changes: 21 additions & 13 deletions url1/category_n.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
)
Expand All @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions url1/category_search.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand All @@ -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 = []

Expand Down

0 comments on commit 6331c9b

Please sign in to comment.