diff --git a/ranked/templates/ranked/player_info.html b/ranked/templates/ranked/player_info.html index 46a447e..d8a8799 100644 --- a/ranked/templates/ranked/player_info.html +++ b/ranked/templates/ranked/player_info.html @@ -154,9 +154,9 @@
labels: ['Wins', 'Losses', 'Draws'], datasets: [{ data: [ - {{player.matches_won}}, - {{player.matches_lost}}, - {{player.matches_drawn}} + {{ player.matches_won }}, + {{ player.matches_lost }}, + {{ player.matches_drawn }} ], backgroundColor: [ '#28a745', @@ -178,10 +178,10 @@
const eloHistoryChart = new Chart(document.getElementById('chart-elo-history').getContext('2d'), { type: 'line', data: { - labels: JSON.parse("{{ match_labels|safe }}"), + labels: {{ match_labels|safe }}, datasets: [{ label: 'ELO', - data: JSON.parse("{{ elo_history|safe }}"), + data: {{ elo_history|safe }}, backgroundColor: '#ffc107', borderColor: '#ffc107' }] diff --git a/ranked/views.py b/ranked/views.py index b3bb3fa..65e0722 100644 --- a/ranked/views.py +++ b/ranked/views.py @@ -126,12 +126,15 @@ def player_info(request, name, player_id): total_matches=Count('red_alliance', filter=Q(red_alliance__in=matches)) + Count('blue_alliance', filter=Q(blue_alliance__in=matches)), wins=Count(Case( - When(Q(red_alliance__in=matches.filter(red_alliance=player.player), red_score__gt=F('blue_score')), then=1), - When(Q(blue_alliance__in=matches.filter(blue_alliance=player.player), blue_score__gt=F('red_score')), then=1), + When(Q(red_alliance__in=matches.filter(red_alliance=player.player)) & + Q(red_alliance__red_score__gt=F('red_alliance__blue_score')), then=1), + When(Q(blue_alliance__in=matches.filter(blue_alliance=player.player)) & + Q(blue_alliance__blue_score__gt=F('blue_alliance__red_score')), then=1), output_field=IntegerField(), )), ties=Count(Case( - When(Q(red_alliance__in=matches) | Q(blue_alliance__in=matches), red_score=F('blue_score'), then=1), + When(Q(red_alliance__in=matches) | Q(blue_alliance__in=matches), + red_alliance__red_score=F('red_alliance__blue_score'), then=1), output_field=IntegerField(), )), ).annotate( @@ -151,12 +154,15 @@ def player_info(request, name, player_id): total_matches=Count('red_alliance', filter=Q(red_alliance__in=matches)) + Count('blue_alliance', filter=Q(blue_alliance__in=matches)), wins=Count(Case( - When(Q(red_alliance__in=matches.filter(blue_alliance=player.player), red_score__gt=F('blue_score')), then=1), - When(Q(blue_alliance__in=matches.filter(red_alliance=player.player), blue_score__gt=F('red_score')), then=1), + When(Q(red_alliance__in=matches.filter(blue_alliance=player.player)) & + Q(red_alliance__red_score__gt=F('red_alliance__blue_score')), then=1), + When(Q(blue_alliance__in=matches.filter(red_alliance=player.player)) & + Q(blue_alliance__blue_score__gt=F('blue_alliance__red_score')), then=1), output_field=IntegerField(), )), ties=Count(Case( - When(Q(red_alliance__in=matches) | Q(blue_alliance__in=matches), red_score=F('blue_score'), then=1), + When(Q(red_alliance__in=matches) | Q(blue_alliance__in=matches), + red_alliance__red_score=F('red_alliance__blue_score'), then=1), output_field=IntegerField(), )), ).annotate(