Open nahoang1104 opened 3 months ago
Add total_goals column to team_ranking class:
total_goals = db.Column(db.Integer, default=0)
Implement update_total_goals:
def update_total_goals(self):
matches = Match.query.filter_by(host_team_id=self.team_id).all()
matches += Match.query.filter_by(guest_team_id=self.team_id).all()
self.total_goals = sum(match.host_score for match in matches if match.host_team_id == self.team_id) + \
sum(match.guest_score for match in matches if match.guest_team_id == self.team_id)
db.session.commit()
also replace r.total_wins with r.total_goals in update_team_rankings pls
Implement head-to-head comparison