def route_match_list(): page = int(request.values.get("page", 1)) pages = (g.cursor.count("matches", "now() > public_date AND active=true") / 25) + 1 g.cursor.execute(MATCH_LIST_QUERY, paginate(page, per_page=25)) matches = map(match_to_json, g.cursor.fetchall()) return APIResponse({ "matches": matches })
def admin_game_list(): page = int(request.values.get("page", 1)) g.cursor.execute("SELECT count(*) as c FROM games") pages = (g.cursor.fetchone().c / 100) + 1 g.cursor.execute(GAMES_LIST_QUERY, paginate(page, per_page=100)) games = [] for entry in g.cursor.fetchall(): games.append({ "id": entry.id, "name": entry.name, "appid": entry.appid, "active": entry.active }) return APIResponse({"games": games, "pages": pages})
def admin_users_list(): page = int(request.values.get("page", 1)) g.cursor.execute("SELECT count(*) as c FROM users") pages = (g.cursor.fetchone().c / 100) + 1 g.cursor.execute(USERS_LIST_QUERY, paginate(page, per_page=100)) users = [] for entry in g.cursor.fetchall(): users.append({ "id": entry.id, "steamid": entry.steamid, "username": gache_nickname(entry.steamid), "last_login": entry.last_login.strftime("%s") if entry.last_login else 0, "active": entry.active }) return APIResponse({"users": users, "pages": pages})
def admin_match_list(): page = int(request.values.get("page", 1)) g.cursor.execute("SELECT count(*) as c FROM matches") pages = (g.cursor.fetchone().c / 100) + 1 g.cursor.execute(MATCHES_LIST_QUERY, paginate(page, per_page=100)) matches = [] for entry in g.cursor.fetchall(): matches.append({ "id": entry.id, "game": entry.game, "teams": entry.teams, "meta": entry.meta, "results": entry.results, "active": entry.active, "lock_date": entry.lock_date.strftime("%s"), "match_date": entry.match_date.strftime("%s"), "public_date": entry.public_date.strftime("%s") }) return APIResponse({"matches": matches, "pages": pages})