Esempio n. 1
0
def obtain_mii(mii_id):
    # Do we have this Mii?
    retrieved_data = (db.session.query(
        ConciergeMiis, MiiData).filter(MiiData.mii_id == mii_id).filter(
            ConciergeMiis.mii_id == MiiData.mii_id).order_by(
                ConciergeMiis.mii_id).first())

    # While one should cause the other to not exist, you never know.
    if retrieved_data is None:
        return exceptions.NotFound()

    concierge_mii, mii_metadata = retrieved_data

    # Next, ensure we have msginfo data for this Mii.
    db_msginfo = (MiiMsgInfo.query.filter_by(mii_id=mii_id).order_by(
        MiiMsgInfo.type.asc()).order_by(MiiMsgInfo.seq.asc()))
    if db_msginfo is None:
        # A Mii doesn't have to be a concierge Mii.
        return exceptions.NotFound()

    # Separate by type and seq.
    # We create a dict where the key is the type and seq/msg are paired by RepeatedKey.
    # We're given in order by type, and then by seq.
    # i.e 1 seq 1, 1 seq 2, 2 seq 1, so forth.
    separate = {}
    for info in db_msginfo:
        if info.type not in separate:
            # Ensure the list exists within the dict.
            separate[info.type] = []

        # As seq/msg can repeat within a single msginfo, we add with a RepeatedKey.
        separate[info.type].append(
            RepeatedElement({
                "seq": info.seq,
                "msg": info.msg,
                "face": info.face
            }))

    # Then, convert all separate types to our actual msginfo type.
    # In these, the type (our previous dict's key) must be separate.
    # This is absolutely horrifying at this point, and I do not envy
    # whoever at Nintendo had to design and store this logic.
    # For the sake of their sanity, I hope this was read off a giant
    # hardcoded array somehow as that feels far more appealing.
    msginfo = []
    for key, value in separate.items():
        msginfo.append(RepeatedElement({"type": key, "msglist": value}))

    return {
        "miiid": mii_id,
        "clothes": concierge_mii.clothes,
        "color1": mii_metadata.color1,
        "color2": mii_metadata.color2,
        "action": concierge_mii.action,
        "prof": concierge_mii.prof,
        "name": mii_metadata.name,
        "msginfo": msginfo,
        "movieid": concierge_mii.movie_id,
        "voice": concierge_mii.voice,
    }
Esempio n. 2
0
def event_today():
    # Retrieve all registered posters.
    queried_posters = Posters.query.order_by(
        Posters.poster_id.asc()).limit(20).all()
    queried_miis = (ConciergeMiis.query.order_by(
        ConciergeMiis.mii_id.asc()).limit(20).all())
    # Create a dictionary and append contents.
    # We require separate posterinfos, so we use RepeatedElement.
    posters = []
    miiinfos = []
    for seq, poster in enumerate(queried_posters):
        posters.append(
            RepeatedElement({
                # Seq is indexed by 1, whereas a normal index is 0.
                "seq": seq + 1,
                "posterid": poster.poster_id,
            }))

    for seq, mii in enumerate(queried_miis):
        miiinfos.append(RepeatedElement({"seq": seq + 1, "miiid": mii.mii_id}))

    return {
        "date":
        current_date(),
        "frameid":
        2,
        "color":
        "000000",
        "postertime":
        5,
        "posterinfo":
        posters,
        "miiinfo":
        miiinfos,
        "newsinfo": {
            "page": 1,
            "news": "Welcome back to Wii Room!"
        },
        "adinfo": (
            RepeatedKey({
                "pref": 2,
                "adid": 1,
            }),
            RepeatedKey({
                "pref": 1,
                "adid": 1,
            }),
        ),
        "introinfo": {
            "seq": 1,
            "cntid": 1,
            "cnttype": 1,
            "dispsec": 5,
            "dimg": 1,
            "random": 0,
            "linktype": 0,
        },
    }
Esempio n. 3
0
def special_page_n(page):
    # TODO: revert from temporary, pre-determined value to database schema
    intro_filler = []
    for i in range(9):
        intro_filler.append(
            RepeatedElement({
                "inmsgseq": i + 1,
                "inmsg": "Hello!",
            }))

    msginfo_filler = []
    for i in range(3):
        msginfo_filler.append(
            RepeatedElement({
                "msgseq": i + 1,
                "msg": "Testing...",
            }))

    return {
        "sppageid": page,
        # TODO: database schema should handle proper times regarding catalog.
        "strdt": current_date_and_time(),
        "enddt": current_date_and_time(),
        "name": "Testing: The Movie",
        "stopflag": 0,
        "level": 1,
        "bgm": 2,
        "mascot": 0,
        "contact": 0,
        "intro": {
            "inmsginfo": intro_filler
        },
        "miiinfo": {
            "seq": 1,
            "miiid": 1,
            "color1": "ffcd00",
            "color2": "000000",
            "msginfo": msginfo_filler,
        },
        "menu": {
            "place": 1,
            "type": 5,
            "imageid": "h1234",
            "link": {
                "linkid": 1,
                "linktitle": "Welcome to nginx",
                "linktype": 0,
                "linkmov": 0,
                "linkpicnum": 1,
                "linkurl": "http://example.com",
                "linkpicbgm": 1,
            },
        },
        "logo": {
            "logo1id": "g1234",
            "logo2id": "f1234"
        },
    }
Esempio n. 4
0
def special_page_n(page):
    query = (db.session.query(Rooms, MiiData, ParadeMiis).filter(
        Rooms.room_id == page).filter(Rooms.room_id == MiiData.mii_id).filter(
            Rooms.room_id == ParadeMiis.mii_id).first())

    if not query:
        return exceptions.NotFound()

    queried_room, queried_mii, queried_parade = query
    menu_data = db.session.query(RoomMenu).filter(Rooms.room_id == page).all()

    menus = []
    for place, data in enumerate(menu_data):
        menus.append(RepeatedElement(data.data | {"place": place + 1}))

    return {
        "sppageid": page,
        # TODO: database schema should handle proper times regarding catalog.
        "strdt": current_date_and_time(),
        "enddt": current_date_and_time(),
        "name": queried_parade.news,
        "stopflag": 0,
        "level": queried_parade.level,
        "bgm": queried_room.bgm.value,
        "mascot": queried_room.mascot,
        "contact": queried_room.contact,
        "intro": {
            "inmsginfo": {
                "inmsgseq": 1,
                "inmsg": queried_room.intro_msg,
            }
        },
        "miiinfo": {
            "seq":
            1,
            "miiid":
            queried_mii.mii_id,
            "color1":
            queried_mii.color1,
            "color2":
            queried_mii.color2,
            "msginfo": [
                RepeatedElement({
                    "msgseq": 1,
                    "msg": queried_room.mii_msg,
                }),
            ],
        },
        "menu": menus,
        "logo": {
            "logo1id": queried_parade.logo_id,
            "logo2id": queried_room.logo2_id
        },
    }
Esempio n. 5
0
def special_all():
    page_info = []

    parade_miis = (db.session.query(ParadeMiis, MiiData).filter(
        ParadeMiis.mii_id == MiiData.mii_id).order_by(ParadeMiis.mii_id).all())

    for parade_mii, mii_data in parade_miis:
        page_info.append(
            RepeatedElement({
                "sppageid":
                mii_data.mii_id,
                "name":
                mii_data.name,
                "level":
                parade_mii.level,
                "miiid":
                mii_data.mii_id,
                "color1":
                mii_data.color1,
                "color2":
                mii_data.color2,
                "logo1id":
                parade_mii.logo_id,
                "news":
                parade_mii.news,
                "valid":
                1,
                "pref":
                "11111111111111111111111111111111111111111111111",
            }))

    return {
        "pageinfo": page_info,
        "upddt": current_date_and_time(),
    }
Esempio n. 6
0
def pay_event_today():
    # Retrieve all registered posters.
    queried_posters = (PayPosters.query.order_by(
        PayPosters.poster_id.asc()).limit(20).all())

    posters = []
    for seq, poster in enumerate(queried_posters):
        posters.append(
            RepeatedElement({
                "seq": seq + 1,
                "posterid": poster.poster_id,
                "geofilter": 0,
            }))

    return {
        "date": current_date(),
        "postertime": 5,
        "posterinfo": posters,
        "introinfo": {
            "seq": 1,
            "cntid": 1,
            "cnttype": 1,
            "dispsec": 5,
            "dimg": 1,
            "random": 0,
            "linktype": 5,
            "linkid": 1,
        },
    }
Esempio n. 7
0
def special_allbin():
    bin_info = []

    # Join queries. We select all ParadeMii data alongside MiiData table data with equal Mii IDs.
    # TODO: determine maximum limit we can select and return.
    parade_miis = (
        db.session.query(ParadeMiis, MiiData)
        .filter(ParadeMiis.mii_id == MiiData.mii_id)
        .order_by(ParadeMiis.mii_id)
        .all()
    )

    # We now have a tuple with ParadeMii data in index 0 and MiiData in index 1.
    for parade_mii, mii_data in parade_miis:
        bin_info.append(
            RepeatedElement(
                {
                    "sppageid": mii_data.mii_id,
                    "miiid": mii_data.mii_id,
                    "miibin": mii_data.data,
                    "logo1id": parade_mii.logo_id,
                    "logobin": parade_mii.logo_bin,
                }
            )
        )

    return {
        "bininfo": bin_info,
    }
Esempio n. 8
0
def search_movies(category_id):
    retrieved_data = (db.session.query(PayCategoriesPosters).filter(
        PayCategoriesPosters.category_id == category_id).order_by(
            PayCategoriesPosters.movieid).all())
    results = []

    if not retrieved_data:
        # Looks like this category does not exist, or contains no movies.
        return exceptions.NotFound()

    for i, paycategoryposters in enumerate(retrieved_data):
        results.append(
            RepeatedElement({
                "rank": paycategoryposters.rank,
                "movieid": paycategoryposters.movieid,
                "title": paycategoryposters.title,
                "strdt": current_date_and_time(),
                "pop": paycategoryposters.pop,
                "kana": 12345678,
                "refid": "01234567890123456789012345678912",
                "released": paycategoryposters.release_date,
                "term": 1,
                "price": paycategoryposters.price,
            }))

    return {
        "num": paycategoryposters.num,
        "categid": category_id,
        "movieinfo": results,
    }
Esempio n. 9
0
def list_category_search(categ_id):
    retrieved_data = (db.session.query(
        CategoryMovies,
        Movies).filter(CategoryMovies.category_id == categ_id).filter(
            CategoryMovies.movie_id == Movies.movie_id).order_by(
                Movies.movie_id).all())
    results = []

    if not retrieved_data:
        # Looks like this category does not exist, or contains no movies.
        return exceptions.NotFound()

    for i, data in enumerate(retrieved_data):
        _, movie_data = data

        # Items must be indexed by 1.
        results.append(
            RepeatedElement({
                "rank": i + 1,
                "movieid": movie_data.movie_id,
                "title": movie_data.title,
                "genre": movie_data.genre,
                "strdt": current_date_and_time(),
                "pop": 0,
            }))

    return {
        "num": 1,
        "categid": categ_id,
        "movieinfo": results,
    }
Esempio n. 10
0
def special_page_n(page):
    query = (db.session.query(Rooms, MiiData, ParadeMiis).filter(
        Rooms.room_id == page).filter(Rooms.room_id == MiiData.mii_id).filter(
            Rooms.room_id == ParadeMiis.mii_id).first())

    if not query:
        return exceptions.NotFound()

    queried_room, queried_mii, queried_parade = query

    return {
        "sppageid": page,
        # TODO: database schema should handle proper times regarding catalog.
        "strdt": current_date_and_time(),
        "enddt": current_date_and_time(),
        "name": queried_parade.news,
        "stopflag": 0,
        "level": queried_parade.level,
        "bgm": queried_room.bgm.value,
        "mascot": queried_room.mascot,
        "contact": queried_room.contact,
        "intro": {
            "inmsginfo": {
                "inmsgseq": 1,
                "inmsg": queried_room.intro_msg,
            }
        },
        "miiinfo": {
            "seq":
            1,
            "miiid":
            queried_mii.mii_id,
            "color1":
            queried_mii.color1,
            "color2":
            queried_mii.color2,
            "msginfo": [
                RepeatedElement({
                    "msgseq": 1,
                    "msg": queried_room.mii_msg,
                }),
            ],
        },
        "menu": {
            "place": 1,
            "type": 4,
            "imageid": "d1234",
            "coup": {
                "coupid": 1,
                "couptitle": "coupon test",
                "couplimit": 10,
                "coupmov": 1,
                "coupmovap": 0,
            },
        },
        "logo": {
            "logo1id": queried_parade.logo_id,
            "logo2id": queried_room.logo2_id
        },
    }
Esempio n. 11
0
def pay_event_today_v1025(queried_posters):
    posters = []
    for seq, poster in enumerate(queried_posters):
        posters.append(
            RepeatedElement({
                "seq": seq + 1,
                "posterid": poster.poster_id,
                "geofilter": 0,
            }))

    return {
        "date": current_date(),
        "postertime": 5,
        "posterinfo": posters,
        "introinfo": {
            "seq": 1,
            "cntid": 1,
            "cnttype": 1,
            "dispsec": 5,
            "dimg": 1,
            "random": 0,
            "linktype": 5,
            "linkid": 1,
        },
    }
Esempio n. 12
0
def search():
    q = request.args.get("q")
    if q is None:
        return {"num": 1, "categid": 12345}

    s = es.search(index="tv_index", body={"query": {"match": {"title": q}}})
    shows = s["hits"]["hits"]

    show_ids = {}
    for i in shows:
        show_ids[i["_source"]["id"]] = i["_source"]["title"]

    movieinfos = []
    rank = 0
    has_results = False
    if len(shows) != 0:
        has_results = True
        for i in show_ids.keys():
            rank += 1
            movieinfos.append(
                RepeatedElement({
                    "rank": rank,
                    "movieid": i,
                    "title": show_ids[i],
                    "genre": 1,
                    "strdt": current_date_and_time(),
                    "pop": 0,
                }))
    if has_results:
        return {"num": 1, "categid": 12345, "movieinfo": movieinfos}
    else:
        return {"num": 1, "categid": 12345}
Esempio n. 13
0
def pay_list_category(list_id: int):
    queried_categories = PayCategories.query.order_by(
        PayCategories.name.asc()).all()

    retrieved_data = (db.session.query(PayCategories).filter(
        PayCategories.genre_id == list_id).order_by(
            PayCategories.category_id).all())
    filler = []

    if list_id <= 9:
        for i, pay_categories in enumerate(queried_categories):
            # Items must be indexed by 1.
            filler.append(
                RepeatedElement({
                    "place": i + 1,
                    "categid": pay_categories.category_id,
                    "name": pay_categories.name,
                    "sppageid": 0,
                    "splinktext": "Link Text",
                }))
    else:
        if not retrieved_data:
            # Looks like this category does not exist, or contains no movies.
            return exceptions.NotFound()

        for i, pay_categories in enumerate(retrieved_data):
            # This section allows us to sort the categories into genres
            # Instead of them showing up in all of the genres
            filler.append(
                RepeatedElement({
                    "place": i + 1,
                    "categid": pay_categories.category_id,
                    "name": pay_categories.name,
                    "sppageid": 0,
                    "splinktext": "Link Text",
                }))

    return {
        "type": 3,
        "img": 1,
        "categinfo": filler,
    }
Esempio n. 14
0
def related():
    # Hardcoded for now
    movie_info = []
    for num in range(15):
        movie_info.append(
            RepeatedElement({
                "rank": num + 1,
                "movieid": 2,
                "title": "Flight of a Shiba"
            }))

    return {"leftmovieinfo": movie_info, "rightmovieinfo": movie_info}
Esempio n. 15
0
def menu_list(request):
    shop_code = request.args.get("shopCode")
    query = (MenuList.query.filter_by(shop_code=shop_code).order_by(
        MenuList.menu_code.asc()).all())
    data = []

    for menu in query:
        data.append(
            RepeatedElement({
                "menuCode": menu.menu_code,
                "linkTitle": menu.title,
                "enabledLink": 1,
                "name": menu.title,
                "info": menu.info,
                "setNum": 0,
                "lunchMenuList": {
                    "isLunchTimeMenu": 1,
                    "hour": {
                        "start": 1,
                        "end": 1,
                    },
                    "isOpen": 1,
                },
                "message": "Where does this show up?",
            }))

    return {
        "response": {
            "menu": data,
            # Placeholder menu item so the rest can show
            "menu2": {
                "menuCode": 2,
                "linkTitle": "More food!",
                "enabledLink": 1,
                "name": "Amazing food",
                "info": "Screamingly delightful.",
                "setNum": 0,
                "lunchMenuList": {
                    "isLunchTimeMenu": 1,
                    "hour": {
                        "start": 1,
                        "end": 1,
                    },
                    "isOpen": 1,
                },
                "message": "Where does this show up?",
            },
        }
    }
Esempio n. 16
0
def pay_list_category_header():
    # TODO: revert from temporary, pre-determined value to database schema
    filler = []
    for i in range(40):
        # Items must be indexed by 1.
        filler.append(
            RepeatedElement({
                "place": i + 1,
                "type": i + 10,
                "text": "Testing...",
            }))

    return {
        "img": 0,
        "listinfo": filler,
    }
Esempio n. 17
0
def pay_list_category_header():
    queried_categories = PayCategoryHeaders.query.order_by(
        PayCategoryHeaders.title.asc()).all()
    filler = []
    for i, pay_category_headers in enumerate(queried_categories):
        # Titles must be indexed by 1.
        filler.append(
            RepeatedElement({
                "place": i + 1,
                "type": i + 10,
                "text": pay_category_headers.title,
            }))

    return {
        "img": 0,
        "listinfo": filler,
    }
Esempio n. 18
0
def new_all():
    queried_categories = NewMovies.query.order_by(NewMovies.title.asc()).all()
    filler = []
    for i, new_movies in enumerate(queried_categories):
        # Items must be indexed by 1.
        filler.append(
            RepeatedElement({
                "rank": i + 1,
                "movieid": new_movies.movie_id,
                "title": new_movies.title,
                "genre": 1,
                "strdt": current_date_and_time(),
                "pop": 0,
            }))

    return {
        "movieinfo": filler,
    }
Esempio n. 19
0
def popular_all():
    # TODO: revert from temporary, pre-determined value to database schema
    filler = []
    for i in range(3):
        # Items must be indexed by 1.
        filler.append(
            RepeatedElement({
                "rank": i + 1,
                "movieid": 1,
                "title": "Shiba: The Movie",
                "genre": 1,
                "strdt": current_date_and_time(),
                "pop": 0,
            }))

    return {
        "movieinfo": filler,
    }
Esempio n. 20
0
def pay_list_category(list_id):
    queried_categories = (PayCategories.query.order_by(
        PayCategories.name.asc()).all())
    filler = []
    for i, pay_categories in enumerate(queried_categories):
        # Items must be indexed by 1.
        filler.append(
            RepeatedElement({
                "place": i + 1,
                "categid": pay_categories.category_id,
                "name": pay_categories.name,
                "sppageid": 0,
                "splinktext": "Link Text",
            }))

    return {
        "type": 3,
        "img": 0,
        "categinfo": filler,
    }
Esempio n. 21
0
def list_category_n(list_id):
    queried_categories = (Categories.query.order_by(
        Categories.name.asc()).limit(64).all())
    results = []

    for i, category in enumerate(queried_categories):
        # Items must be indexed by 1.
        results.append(
            RepeatedElement({
                "place": i + 1,
                "categid": category.category_id,
                "name": category.name,
                "sppageid": 0,
                "splinktext": "Link text",
            }))

    return {
        "type": 3,
        "categinfo": results,
    }
Esempio n. 22
0
def popular_n(id):
    # TODO: revert from temporary, pre-determined value to database schema
    filler = []
    for i in range(3):
        # Items must be indexed by 1.
        filler.append(
            RepeatedElement({
                "place": i + 1,
                "categid": 12345,
                "name": "Category text",
                "sppageid": 1,
                "splinktext": "Link text",
            }))

    response = {
        "type": 1,
        "categinfo": filler,
    }
    # The ID 02 requires a type of 3.
    if id == "02":
        response["type"] = 3

    return response
Esempio n. 23
0
def basket_list(request):
    zip_code = request.args.get("areaCode")
    query = UserOrders.query.filter_by(zip_code=zip_code).first()

    # Since basketReset sends the authKey instead of the areaCode, we will append the authKey to the database.
    # This is the only request in the channel that does this, which is very very annoying but oh well
    query.auth_key = request.args.get("authKey")
    db.session.commit()
    price = 0

    # Subtract the amount of indices in the list by 2 to get the amount we have to range over
    num = len(query.basket)
    data = []

    for i in range(num):
        price = int(query.basket[i]["price"]) * int(
            query.basket[i]["qty"]) + price
        data.append(
            RepeatedElement({
                "basketNo": i,
                "menuCode": 1,
                "itemCode": 1,
                "name": query.basket[i]["name"],
                "price": query.basket[i]["price"],
                "size": 1,
                "isSoldout": 0,
                "quantity": query.basket[i]["qty"],
                "subTotalPrice": 1,
                "Menu": {
                    "name": "Menu",
                    "lunchMenuList": {
                        "isLunchTimeMenu": 1,
                        "isOpen": 1,
                    },
                },
                "optionList": {
                    "testing": {
                        "info": "Here so everything works!",
                        "code": 1,
                        "type": 1,
                        "name": "WiiLink",
                        "list": {
                            "item_one": {
                                "name": "Item One",
                                "menuCode": 1,
                                "itemCode": 1,
                                "image": 1,
                                "isSoldout": 0,
                                "info": "Here so everything works!",
                                "price": "5.99",
                            }
                        },
                    }
                },
            }))
    return {
        "basketPrice": price,
        "totalPrice": price,
        "Status": {
            "isOrder": 1,
            "messages": {
                "hey": "how are you?"
            }
        },
        "List": {
            "generic": data
        },
    }
Esempio n. 24
0
def event_today():
    # Retrieve all registered posters.
    queried_posters = Posters.query.order_by(
        Posters.poster_id.asc()).limit(20).all()
    queried_miis = (ConciergeMiis.query.order_by(
        ConciergeMiis.mii_id.asc()).limit(20).all())
    # Create a dictionary and append contents.
    # We require separate posterinfos, so we use RepeatedElement.
    posters = []
    miiinfos = []
    newsinfos = []
    for seq, poster in enumerate(queried_posters):
        posters.append(
            RepeatedElement({
                # Seq is indexed by 1, whereas a normal index is 0.
                "seq": seq + 1,
                "posterid": poster.poster_id,
            }))

    for seq, mii in enumerate(queried_miis):
        miiinfos.append(RepeatedElement({"seq": seq + 1, "miiid": mii.mii_id}))
    for page, news in enumerate(News.query.all()):
        newsinfos.append(RepeatedElement({"page": page + 1, "news": news.msg}))

    return_dict = {
        "date":
        current_date(),
        "frameid":
        2,
        "color":
        "000000",
        "postertime":
        5,
        "posterinfo":
        posters,
        "adinfo": (
            RepeatedKey({
                "pref": 2,
                "adid": 1,
            }),
            RepeatedKey({
                "pref": 1,
                "adid": 1,
            }),
        ),
        "introinfo": {
            "seq": 1,
            "cntid": 1,
            "cnttype": 1,
            "dispsec": 5,
            "dimg": 1,
            "random": 0,
            "linktype": 0,
        },
    }

    if is_v770():
        # v770 expects only one poster.
        # As we've already queried the DB, insert the first poster.
        poster_id = posters[0].contents["posterid"]
        return_dict["posterid"] = poster_id
    else:
        # v1025 expects multiple posters, similar to how we've queried.
        return_dict["posterinfo"] = posters

    if newsinfos:
        return_dict["newsinfo"] = newsinfos

    if miiinfos:
        return_dict["miiinfo"] = miiinfos

    return return_dict