コード例 #1
0
ファイル: report.py プロジェクト: optionalg/djangoctf
 def handle(self, *args, **options):
     print("""
     ===================================================
     Total users: {}
     Total teams: {}
     Users/team: {}
     Eligible teams: {}
     
     Total problems: {}
     Total submissions: {}
     Scoring teams: {}
     
     Countries: {}
     States: {}
     ===================================================
     """.format(
         User.objects.count(),
         Team.current().count(),
         Team.current().annotate(count=Count("members")).aggregate(
             Avg("count"))['count__avg'],
         Team.current().filter(eligible=True).count(),
         Problem.current().count(),
         Problem.current().annotate(count=Count("solves")).aggregate(
             Sum("count"))['count__sum'],
         Team.current().filter(score__gt=0).count(),
         Team.current().filter(score__gt=0).values(
             "members__profile__country").distinct().count(),
         Team.current().filter(score__gt=0).values(
             "members__profile__state").distinct().count()))
コード例 #2
0
    def handle(self, *args, **options):

        for i, team in enumerate(Team.current().all()):
            score = 0

            team.solved.clear()

            for submission in Submission.objects.all().filter(team=team).order_by('time'):
                score += submission.problem.value
                submission.new_score = score
                submission.save()
                team.solved.add(submission.problem)

            team.score = score
            team.save()

            print("Fixed score for team {%d}/{%d}" % (i, Team.objects.count()))