コード例 #1
0
ファイル: team.py プロジェクト: quinnromanek/dynasty2
 def point_diff(self):
     try:
         home_scores = self.home_game.filter(season=current_season().year, week__gte=0).aggregate(
             team_score=Sum('homeScore'), opp_score=Sum('awayScore'))
         away_scores = self.away_game.filter(season=current_season().year, week__gte=0).aggregate(
             team_score=Sum('awayScore'), opp_score=Sum('homeScore'))
         if home_scores['team_score'] is None: home_scores['team_score'] = 0
         if home_scores['opp_score'] is None: home_scores['opp_score'] = 0
         if away_scores['team_score'] is None: away_scores['team_score'] = 0
         if away_scores['opp_score'] is None: away_scores['opp_score'] = 0
         return (home_scores['team_score'] + away_scores['team_score'] - home_scores['opp_score'] - away_scores[
             'opp_score']) / float(self.wins + self.losses)
     except ZeroDivisionError:
         return 0.0
コード例 #2
0
ファイル: team.py プロジェクト: quinnromanek/dynasty2
 def div_rank(self):
     agg = seed(
         list(
             Team.objects.filter(division=self.division).order_by("-wins")),
         current_season())
     for i in range(len(agg)):
         if agg[i].id == self.id:
             return i + 1
コード例 #3
0
ファイル: team.py プロジェクト: quinnromanek/dynasty2
 def point_diff(self):
     try:
         home_scores = self.home_game.filter(
             season=current_season().year,
             week__gte=0).aggregate(team_score=Sum('homeScore'),
                                    opp_score=Sum('awayScore'))
         away_scores = self.away_game.filter(
             season=current_season().year,
             week__gte=0).aggregate(team_score=Sum('awayScore'),
                                    opp_score=Sum('homeScore'))
         if home_scores['team_score'] is None: home_scores['team_score'] = 0
         if home_scores['opp_score'] is None: home_scores['opp_score'] = 0
         if away_scores['team_score'] is None: away_scores['team_score'] = 0
         if away_scores['opp_score'] is None: away_scores['opp_score'] = 0
         return (home_scores['team_score'] + away_scores['team_score'] -
                 home_scores['opp_score'] -
                 away_scores['opp_score']) / float(self.wins + self.losses)
     except ZeroDivisionError:
         return 0.0
コード例 #4
0
ファイル: player.py プロジェクト: quinnromanek/dynasty2
 def apg_season(self):
     spg = self.playerstats_set.filter(game__season=current_season().year).aggregate(Avg('assists'))['assists__avg']
     if spg is None:
         return 0.0
     return spg
コード例 #5
0
ファイル: player.py プロジェクト: quinnromanek/dynasty2
 def rpg_season(self):
     rpg = self.playerstats_set.filter(game__season=current_season().year).aggregate(Avg('rebounds'))['rebounds__avg']
     if rpg is None:
         return 0.0
     return rpg
コード例 #6
0
ファイル: player.py プロジェクト: quinnromanek/dynasty2
    def ppg_season(self):
        fgpg = self.playerstats_set.filter(game__season=current_season().year).aggregate(Avg('field_goals'))['field_goals__avg']

        if fgpg is None:
            return 0.0
        return fgpg * 2
コード例 #7
0
def regular_season_games(team):
    return Game.objects.filter(Q(away_team__id=team.id)
                               | Q(home_team__id=team.id),
                               week__gte=0,
                               season=current_season().year).order_by('week')
コード例 #8
0
ファイル: contract.py プロジェクト: quinnromanek/dynasty2
    def years_left(self, season=None):
        if season is None:
            season = current_season()

        return self.start - season.year + self.years
コード例 #9
0
ファイル: team.py プロジェクト: quinnromanek/dynasty2
 def div_rank(self):
     agg = seed(list(Team.objects.filter(division=self.division).order_by("-wins")), current_season())
     for i in range(len(agg)):
         if agg[i].id == self.id:
             return i + 1
コード例 #10
0
    def years_left(self, season=None):
        if season is None:
            season = current_season()

        return self.start - season.year + self.years