Esempio n. 1
0
def get_coach_stats(coach_id):
    """get coach with detailed info"""
    coach = Coach.query.options(selectinload(Coach.packs)).get(coach_id)
    season = request.args.get("season", current_season())
    if coach is None:
        abort(404)
    return etagjsonify(coach.stats(season))
Esempio n. 2
0
def get_tournaments():
    """returns all tournaments as json"""
    all_tournaments = Tournament.query.options(raiseload(
        Tournament.coaches)).filter(Tournament.status.in_(
            ("OPEN", "RUNNING"))).all()

    result = tournaments_schema.dump(all_tournaments)
    return etagjsonify(result.data)
Esempio n. 3
0
def get_coaches_leaderboard():
    """return leaderboard json"""
    season = request.args.get("season", current_season())
    stats = StatsHandler(season)
    result = {}
    result['coaches'] = stats.get_stats()['coaches_extra']
    result['coach_stats'] = list(stats.get_stats()['coaches'].values())
    return etagjsonify(result)
Esempio n. 4
0
def get_coach(coach_id):
    """get coach with detailed info"""
    coach = Coach.query.options(selectinload(Coach.packs)).get(coach_id)
    if coach is None:
        abort(404)
    result = coach_schema.dump(coach)
    if not owning_coach(coach):
        CardHelper.censor_cards(result.data['cards'])
    return etagjsonify(result.data)
Esempio n. 5
0
def seasons():
    """return  config"""
    return etagjsonify(seasons=app.config['SEASONS'], high_command_prices = HC_PRICES)
Esempio n. 6
0
def bb2_names():
    """return  bb2_names"""
    bb2_names = sorted(list(StatsHandler().get_stats()['coaches'].keys()))
    return etagjsonify(names=bb2_names)
Esempio n. 7
0
def get_coaches():
    """returns all coaches as json"""
    all_coaches = Coach.query.options(raiseload(Coach.cards),
                                      raiseload(Coach.packs)).all()
    result = coaches_schema.dump(all_coaches)
    return etagjsonify(result.data)