Skip to content

Commit

Permalink
feat: Support concierge categories in search
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jul 1, 2024
1 parent 39cb435 commit 9832029
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 27 deletions.
71 changes: 51 additions & 20 deletions url1/category_n.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
from models import Categories, Rooms
from models import Categories, Rooms, ConciergeMiis, MiiData
from room import app, db
from helpers import xml_node_name, RepeatedElement


@app.route("/url1/list/category/<list_id>.xml")
@xml_node_name("CategoryList")
def list_category_n(list_id):
queried_data = (
db.session.query(Categories, Rooms)
.filter(Categories.sp_page_id == Rooms.room_id)
.order_by(Categories.name.asc())
.limit(64)
.all()
)
# list_id:
# 01: All
# 02: Miis
# 03: Rooms
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()
)

for i, category in enumerate(queried_data):
# 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,
}
for i, category in enumerate(queried_data):
# 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,
}
)
)
case "02":
concierge_miis = (
db.session.query(ConciergeMiis, MiiData)
.filter(ConciergeMiis.mii_id == MiiData.mii_id)
.all()
)
)

for i, mii in enumerate(concierge_miis):
# Items must be indexed by 1.
results.append(
RepeatedElement(
{
"place": i + 1,
# Category ID must be 5 digits.
"categid": 20000 + mii[0].mii_id,
"name": mii[1].name,
# The following are unused in this context.
"sppageid": 0,
"splinktext": "Placeholder",
}
)
)
case "03":
# TODO: Rooms
pass

return {
"type": 3,
Expand Down
27 changes: 20 additions & 7 deletions url1/category_search.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
from werkzeug import exceptions

from models import Movies
from models import Movies, ConciergeMovies
from room import app
from helpers import xml_node_name, RepeatedElement, current_date_and_time


@app.route("/url1/list/category/search/<categ_id>")
@app.route("/url1/list/category/search/<int:categ_id>")
@xml_node_name("SearchMovies")
def list_category_search(categ_id):
retrieved_data = (
Movies.query.filter(Movies.category_id == categ_id)
.order_by(Movies.date_added.desc())
.all()
)
if categ_id < 20000:
retrieved_data = (
Movies.query.filter(Movies.category_id == categ_id)
.order_by(Movies.date_added.desc())
.all()
)
elif 20000 <= categ_id <= 29999:
# Concierge Movies
retrieved_data = (
Movies.query.filter(Movies.movie_id == ConciergeMovies.movie_id)
.filter(ConciergeMovies.mii_id == categ_id - 20000)
.order_by(Movies.date_added.desc())
.all()
)
else:
# TODO: This will be rooms
retrieved_data = None

results = []

if not retrieved_data:
Expand Down

0 comments on commit 9832029

Please sign in to comment.