Fix out of index in stat page
This commit is contained in:
parent
04a20626b8
commit
5c5bba5f7b
1 changed files with 9 additions and 9 deletions
|
@ -561,16 +561,16 @@ class ContestStats(TitleMixin, ContestMixin, DetailView):
|
||||||
result_data[category['code']][i] = category['count']
|
result_data[category['code']][i] = category['count']
|
||||||
|
|
||||||
problem_points = [[] for _ in range(num_problems)]
|
problem_points = [[] for _ in range(num_problems)]
|
||||||
point_count = queryset.values('contest__problem__order', 'contest__points')\
|
point_count_queryset = list(queryset.values('problem__code', 'contest__points', 'contest__problem__points')
|
||||||
.annotate(count=Count('contest__points')) \
|
.annotate(count=Count('contest__points'))
|
||||||
.filter(points__isnull=False) \
|
.filter(points__isnull=False)
|
||||||
.order_by('contest__problem__order', 'contest__points')
|
.order_by('problem__code', 'contest__points')
|
||||||
|
.values_list('problem__code', 'contest__points', 'contest__problem__points', 'count'))
|
||||||
counter = [[0 for _ in range(self.POINT_BIN + 1)] for _ in range(num_problems)]
|
counter = [[0 for _ in range(self.POINT_BIN + 1)] for _ in range(num_problems)]
|
||||||
for sub in point_count.iterator():
|
for problem_code, point, max_point, count in point_count_queryset:
|
||||||
problem_idx = sub['contest__problem__order'] - 1
|
problem_idx = codes.index(problem_code)
|
||||||
bin_idx = math.floor(sub['contest__points'] * self.POINT_BIN / 100)
|
bin_idx = math.floor(point * self.POINT_BIN / max_point)
|
||||||
counter[problem_idx][bin_idx] += sub['count']
|
counter[problem_idx][bin_idx] += count
|
||||||
for i in range(num_problems):
|
for i in range(num_problems):
|
||||||
problem_points[i] = [(j * 100 / self.POINT_BIN, counter[i][j])
|
problem_points[i] = [(j * 100 / self.POINT_BIN, counter[i][j])
|
||||||
for j in range(len(counter[i]))]
|
for j in range(len(counter[i]))]
|
||||||
|
|
Loading…
Reference in a new issue