@user_passes_test(lambda u: u.is_superuser)
def results(request):
    vote_results = [];

    categories = Category.objects.filter(type=TYPE.VOTED).order_by('id')
    totals = {}
    for t in Vote.objects.values('category').annotate(total=Count('category')):
        totals[t['category']] = t['total']

    for category in categories:
        votes = Vote.objects.filter(category=category).values('team').annotate(
            votes=Count('id')).order_by('votes').reverse()

        votes = [{'votes': v['votes'],
                  'percentage': _get_percentage(v['votes'], totals[category.id]),
                  'team': Team.objects.get(id=v['team'])}
                for v in votes][:10]
        if request.GET.keys() in 'goat':
            _fix_votes(votes, totals[category.id])

        vote_results.append({'category': category,
                             'votes': votes,
                             'total': totals.get(category.id, 0)})

    env = {'vote_results': vote_results}
    return render(request, 'voting/results.html', env)
dataset/ETHPy150Open mpirnat/hackday/hackday/voting/views.py/results/swapped operands of `in`