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))
def stats(self,season=current_season()): app = db.get_app() stats = StatsHandler(season) stats_data = stats.get_stats() if self.bb2_name: coach_stats = stats_data['coaches'].get(self.bb2_name, {}) return coach_stats return {}
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)
def __init__(self,**kwargs): super(Transaction, self).__init__(**kwargs) self.season = current_season()
def active_cards(self): return Card.query.join(Card.pack).filter(Pack.coach_id == self.id).filter(Pack.season == current_season()).all()
def earned(self): cash = 0 for tr in self.account.transactions: if tr.price<0 and tr.season==current_season(): cash += -1*tr.price return cash
def __init__(self,**kwargs): super(Pack, self).__init__(**kwargs) self.season = current_season()
def __init__(self, season=None): if not season: season = current_season() self.__season = season