Skip to content

Commit 8c951e6

Browse files
committed
refactor(organization): clean up inline dependencies and improve code style
1 parent ef7b722 commit 8c951e6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

judge/management/commands/backfill_problem_data_size.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
3+
from django.conf import settings
14
from django.core.management.base import BaseCommand
25

36
from judge.models import ProblemData
@@ -19,9 +22,6 @@ def handle(self, *args, **options):
1922
if dry_run:
2023
self.stdout.write(self.style.WARNING('DRY RUN MODE - No changes will be saved'))
2124

22-
from django.conf import settings
23-
import os
24-
2525
problem_data_list = ProblemData.objects.all().iterator(chunk_size=5000)
2626
total_count = ProblemData.objects.count()
2727
updated_count = 0

judge/models/profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ def get_max_storage(self):
161161
return settings.VNOJ_ORGANIZATION_DEFAULT_MAX_STORAGE
162162

163163
def get_current_problem_count(self):
164-
from judge.models import Problem
165-
return Problem.objects.filter(organization=self).count()
164+
return self.problem_set.count()
166165

167166
def get_current_storage(self):
168-
from judge.models import ProblemData
167+
from django.apps import apps
168+
ProblemData = apps.get_model('judge', 'ProblemData')
169169
result = ProblemData.objects.filter(
170170
problem__organization=self,
171171
).aggregate(total=Sum('zipfile_size'))

0 commit comments

Comments
 (0)