From 8601532ae5d7d90e0ba2a77bd14307146ef1b983 Mon Sep 17 00:00:00 2001 From: Michael Wittig Date: Wed, 5 Oct 2016 08:08:16 +0200 Subject: [PATCH] show bounds which one already overcome but is not less than min(awps) --- core/ofm_views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/ofm_views.py b/core/ofm_views.py index 31735e7..c252245 100644 --- a/core/ofm_views.py +++ b/core/ofm_views.py @@ -154,22 +154,23 @@ def get(self, request, *args, **kwargs): season_number = self.request.GET.get('season_number', default=current_season_number) player_id = self.request.GET.get('player_id') player = Player.objects.filter(id=player_id) - data_source = PlayerStatistics.objects.filter(player=player, matchday__season__number=season_number) - awps = [player_stat.awp for player_stat in data_source] + player_statistics = PlayerStatistics.objects.filter(player=player, matchday__season__number=season_number) + awps = [player_stat.awp for player_stat in player_statistics] chart_json = { "series": [{ "name": 'AWP', "data": awps }], - "categories": [player_stat.matchday.number for player_stat in data_source] + "categories": [player_stat.matchday.number for player_stat in player_statistics] } awp_boundaries = AwpBoundaries.get_from_matchday(Matchday.objects.all()[0]) bound_displayed = False for strength in awp_boundaries: + if awp_boundaries[strength] >= min(awps) and not bound_displayed: + chart_json['series'].append({'name': 'AWP-Grenze: %s' % strength, 'data': [awp_boundaries[strength]] * len(player_statistics)}) if awp_boundaries[strength] >= max(awps) and not bound_displayed: - chart_json['series'].append({'name': 'AWP-Grenze: %s' % strength, 'data': [awp_boundaries[strength]] * len(data_source)}) bound_displayed = True return self.render_json_response(chart_json)