<commit_before>from django.shortcuts import render
from django.views import generic

from allauthdemo.auth.models import DemoUser
from allauthdemo.demo.models import Problem
from fileupload.models import Submission
from allauthdemo.demo.models import ContestParticipation


class ProblemView(generic.ListView):
	model = Problem
	template_name = '../templates/bases/problem-list.html'
	context_object_name = 'problems_retrieved'

	def get_queryset(self):
		return Problem.objects.all()


class SubmissionView(generic.ListView):
    model = Submission
    template_name = '../templates/bases/submission-list.html'
    context_object_name = 'submissions'

    def get_queryset(self):
        good_result = []
        bad_result = []
        submissions = Submission.objects.filter(user=self.request.user)
        for problem in Problem.objects.all():
            submission = submissions.filter(problem=problem).order_by('-last_modified').first()
            if submission:
                good_result.append(submission)
            else:
                bad_result.append(problem)
        return {'good': good_result, 'bad':bad_result}


class RankingView(generic.TemplateView):
    template_name = '../templates/bases/ranking-list.html'

    def get_context_data(self, **kwargs):
        context = super(RankingView, self).get_context_data(**kwargs)
        users = []
        for user in DemoUser.objects.all():
            d = {}
            d['name'] = user.get_full_name()

            d['homework_points'] = 0
            submissions = Submission.objects.filter(user=user)
            problem_ids = set()
            for submission in submissions:
                if submission.problem.id not in problem_ids:
                    problem_ids.add(submission.problem.id)
                    d['homework_points'] += submission.problem.score

            d['codeforces_points'] = sum([x.score for x in ContestParticipation.objects.filter(user=user)])
            d['no_stress'] = user.score_fmi_no_stress / 20
            d['csacademy'] = user.score_csacademy / 20
            d['max_points'] = 100 if user.school_year == 1 else 140
            d['total'] = d['homework_points'] + d['codeforces_points'] + d['no_stress'] + d['csacademy']
            d['nota'] = total / d['max_points'] * 10
            users.append(d)
        context['users'] = users
        return context<commit_msg>Hotfix<commit_after>from django.shortcuts import render
from django.views import generic

from allauthdemo.auth.models import DemoUser
from allauthdemo.demo.models import Problem
from fileupload.models import Submission
from allauthdemo.demo.models import ContestParticipation


class ProblemView(generic.ListView):
	model = Problem
	template_name = '../templates/bases/problem-list.html'
	context_object_name = 'problems_retrieved'

	def get_queryset(self):
		return Problem.objects.all()


class SubmissionView(generic.ListView):
    model = Submission
    template_name = '../templates/bases/submission-list.html'
    context_object_name = 'submissions'

    def get_queryset(self):
        good_result = []
        bad_result = []
        submissions = Submission.objects.filter(user=self.request.user)
        for problem in Problem.objects.all():
            submission = submissions.filter(problem=problem).order_by('-last_modified').first()
            if submission:
                good_result.append(submission)
            else:
                bad_result.append(problem)
        return {'good': good_result, 'bad':bad_result}


class RankingView(generic.TemplateView):
    template_name = '../templates/bases/ranking-list.html'

    def get_context_data(self, **kwargs):
        context = super(RankingView, self).get_context_data(**kwargs)
        users = []
        for user in DemoUser.objects.all():
            d = {}
            d['name'] = user.get_full_name()

            d['homework_points'] = 0
            submissions = Submission.objects.filter(user=user)
            problem_ids = set()
            for submission in submissions:
                if submission.problem.id not in problem_ids:
                    problem_ids.add(submission.problem.id)
                    d['homework_points'] += submission.problem.score

            d['codeforces_points'] = sum([x.score for x in ContestParticipation.objects.filter(user=user)])
            d['no_stress'] = user.score_fmi_no_stress / 20
            d['csacademy'] = user.score_csacademy / 20
            d['max_points'] = 100 if user.school_year == 1 else 140
            d['total'] = d['homework_points'] + d['codeforces_points'] + d['no_stress'] + d['csacademy']
            d['nota'] = d['total'] / d['max_points'] * 10
            users.append(d)
        context['users'] = users
        return context
{'fraction_non_alphanumeric': 0.11283557046979865, 'fraction_numerical': 0.00587248322147651, 'mean_word_length': 2.7055167055167053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '324754', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1342, 'n_words': 267}