Skip to content

Commit

Permalink
Remember migrations are annoying
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanB committed Sep 13, 2024
1 parent 205688b commit 21a25ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions ranked/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class Match(models.Model):
red_starting_elo = models.FloatField()
blue_starting_elo = models.FloatField()

winner = models.CharField(max_length=10, choices=[('red', 'Red'), ('blue', 'Blue'), ('draw', 'Draw')])

def get_red_players(self):
return self.red_alliance.all()

Expand Down
8 changes: 4 additions & 4 deletions ranked/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def player_info(request, name, player_id):
)
total_matches = matches_together.count()
wins = matches_together.filter(
(Q(red_alliance=player.player) & Q(red_alliance=played_with) & Q(winner='red')) |
(Q(blue_alliance=player.player) & Q(blue_alliance=played_with) & Q(winner='blue'))
(Q(red_alliance=player.player) & Q(red_alliance=played_with) & Q(red_score__gt=F('blue_score'))) |
(Q(blue_alliance=player.player) & Q(blue_alliance=played_with) & Q(blue_score__gt=F('red_score')))
).count()
win_rate = (wins / total_matches * 100) if total_matches > 0 else 0
players_with_stats.append({
Expand All @@ -156,8 +156,8 @@ def player_info(request, name, player_id):
)
total_matches = matches_against.count()
wins = matches_against.filter(
(Q(red_alliance=player.player) & Q(winner='red')) |
(Q(blue_alliance=player.player) & Q(winner='blue'))
(Q(red_alliance=player.player) & Q(red_score__gt=F('blue_score'))) |
(Q(blue_alliance=player.player) & Q(blue_score__gt=F('red_score')))
).count()
win_rate = (wins / total_matches * 100) if total_matches > 0 else 0
players_against_stats.append({
Expand Down

0 comments on commit 21a25ac

Please sign in to comment.