From f2b7ff9fc1248c9d3b5cd9c4766302af49ed7cda Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:00:50 -0400 Subject: [PATCH] feat: Support multiple Parade Miis in the channel --- url1/special/page.py | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/url1/special/page.py b/url1/special/page.py index 5b91e8ff..350cf0ec 100644 --- a/url1/special/page.py +++ b/url1/special/page.py @@ -12,18 +12,18 @@ @app.route("/url1/special//page.xml") @xml_node_name("SpPage") def special_page_n(page): + room_data = Rooms.query.filter(Rooms.room_id == page).first() + query = ( - db.session.query(Rooms, RoomMiis, MiiData) - .filter(Rooms.room_id == page) - .filter(Rooms.room_id == RoomMiis.room_id) + db.session.query(RoomMiis, MiiData) .filter(RoomMiis.mii_id == MiiData.mii_id) - .first() + .order_by(RoomMiis.seq) + .all() ) if not query: return exceptions.NotFound() - room_data, room_mii, mii_data = query menu_data = db.session.query(RoomMenu).filter(RoomMenu.room_id == page).all() menus = [] @@ -41,10 +41,25 @@ def special_page_n(page): ) ) - mii_msgs = [] - for i, msg in enumerate(room_mii.mii_msg.split("\n")): - mii_msgs.append( - RepeatedElement({"msgseq": i + 1, "msg": "\n".join(wrap(msg, 23))}) + miis = [] + for room_mii, mii_data in query: + mii_msgs = [] + for i, msg in enumerate(room_mii.mii_msg.split("\n")): + mii_msgs.append( + RepeatedElement({"msgseq": i + 1, "msg": "\n".join(wrap(msg, 23))}) + ) + + print(room_mii.seq) + miis.append( + RepeatedElement( + { + "seq": room_mii.seq, + "miiid": mii_data.mii_id, + "color1": mii_data.color1, + "color2": mii_data.color2, + "msginfo": mii_msgs, + }, + ) ) return { @@ -60,13 +75,7 @@ def special_page_n(page): # If we have contact data, we should enable contacting. "contact": room_data.contact_data is not None, "intro": {"inmsginfo": intro_msgs}, - "miiinfo": { - "seq": 1, - "miiid": mii_data.mii_id, - "color1": mii_data.color1, - "color2": mii_data.color2, - "msginfo": mii_msgs, - }, + "miiinfo": miis, "menu": menus, "logo": { # We hardcode all parade logo IDs to g1234.