Boost loading testcases speed and increase submission limit

This commit is contained in:
cuom1999 2020-09-27 01:56:48 -05:00
parent c3eb8eed9b
commit 37f8675f06
2 changed files with 9 additions and 4 deletions

View file

@ -67,7 +67,7 @@ DMOJ_EMAIL_THROTTLING = (10, 60)
DMOJ_STATS_LANGUAGE_THRESHOLD = 10
DMOJ_SUBMISSIONS_REJUDGE_LIMIT = 10
# Maximum number of submissions a single user can queue without the `spam_submission` permission
DMOJ_SUBMISSION_LIMIT = 2
DMOJ_SUBMISSION_LIMIT = 3
DMOJ_BLOG_NEW_PROBLEM_COUNT = 7
DMOJ_BLOG_RECENTLY_ATTEMPTED_PROBLEMS_COUNT = 7
DMOJ_TOTP_TOLERANCE_HALF_MINUTES = 1
@ -500,7 +500,7 @@ try:
except IOError:
pass
TESTCASE_VISIBLE_LENGTH = 60
TESTCASE_VISIBLE_LENGTH = 64
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440

View file

@ -137,6 +137,11 @@ def group_test_cases(cases):
return result
def read_head_archive(archive, file):
with archive.open(file) as f:
return f.read(settings.TESTCASE_VISIBLE_LENGTH + 3)
def get_visible_content(data):
data = data or b''
data = data.replace(b'\r\n', b'\r').replace(b'\r', b'\n')
@ -151,9 +156,9 @@ def get_visible_content(data):
def get_input_answer(case, archive):
result = {'input': '', 'answer': ''}
if (len(case.input_file)):
result['input'] = get_visible_content(archive.read(case.input_file))
result['input'] = get_visible_content(read_head_archive(archive, case.input_file))
if (len(case.output_file)):
result['answer'] = get_visible_content(archive.read(case.output_file))
result['answer'] = get_visible_content(read_head_archive(archive, case.output_file))
return result