Example #1
0
def votes(session):
    data = botinteract.get_data('shows')
    current_game_id = botinteract.get_current_game()
    current_show_id = botinteract.get_show()

    if current_game_id not in data[current_show_id]["games"]:
        current_game_id = None
    shows = [{
        "id":
        show_id,
        "name":
        show.get("name", show_id),
        "games":
        sorted([{
            "id": game_id,
            "name": game["name"],
            "display": game.get("display", game["name"]),
            "vote": game.get("votes", {}).get(session["user"]),
        } for game_id, game in show['games'].items()],
               key=lambda game:
               (1 if game['id'] == current_game_id and show_id ==
                current_show_id else 2, game['display'].upper()))
    } for show_id, show in data.items()]
    shows.sort(key=lambda show:
               (1 if show["id"] == current_show_id and current_game_id is
                not None else 2, show["name"].upper()))

    return flask.render_template("votes.html",
                                 shows=shows,
                                 current_show_id=current_show_id,
                                 current_game_id=current_game_id,
                                 session=session)
Example #2
0
def api_votes():
    game_id = botinteract.get_current_game()
    if game_id is None:
        return "-"
    show = botinteract.get_show()
    data = botinteract.get_data(["shows", show, "games", game_id, "votes"])
    count = len(data)
    good = sum(data.values())
    return "%.0f%% (%d/%d)" % (100 * good / count, good, count)
Example #3
0
def api_stats(stat):
	game_id = botinteract.get_current_game()
	if game_id is None:
		return "-"
	show = botinteract.get_show()
	count = botinteract.get_data(["shows", show, "games", game_id, "stats", stat])
	if not count:
		count = 0
	return str(count)
Example #4
0
def api_votes():
	game_id = botinteract.get_current_game()
	if game_id is None:
		return "-"
	show = botinteract.get_show()
	data = botinteract.get_data(["shows", show, "games", game_id, "votes"])
	count = len(data)
	good = sum(data.values())
	return "%.0f%% (%d/%d)" % (100*good/count, good, count)
Example #5
0
def api_stats(stat):
    game_id = botinteract.get_current_game()
    if game_id is None:
        return "-"
    show = botinteract.get_show()
    count = botinteract.get_data(
        ["shows", show, "games", game_id, "stats", stat])
    if not count:
        count = 0
    return str(count)
Example #6
0
def votes(session):
    data = botinteract.get_data("shows")
    current_game_id = botinteract.get_current_game()
    current_show_id = botinteract.get_show()

    if current_game_id not in data[current_show_id]["games"]:
        current_game_id = None
    shows = [
        {
            "id": show_id,
            "name": show.get("name", show_id),
            "games": sorted(
                [
                    {
                        "id": game_id,
                        "name": game["name"],
                        "display": game.get("display", game["name"]),
                        "vote": game.get("votes", {}).get(session["user"]),
                    }
                    for game_id, game in show["games"].items()
                ],
                key=lambda game: (
                    1 if game["id"] == current_game_id and show_id == current_show_id else 2,
                    game["display"].upper(),
                ),
            ),
        }
        for show_id, show in data.items()
    ]
    shows.sort(
        key=lambda show: (
            1 if show["id"] == current_show_id and current_game_id is not None else 2,
            show["name"].upper(),
        )
    )

    return flask.render_template(
        "votes.html", shows=shows, current_show_id=current_show_id, current_game_id=current_game_id, session=session
    )
Example #7
0
def get_show():
    return botinteract.get_show()
Example #8
0
def get_show():
	return botinteract.get_show()