Skip to content

Commit

Permalink
Fixed string truncation (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
metenn authored Jan 10, 2024
1 parent 3bb282d commit f901567
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions oioioi/programs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,8 @@ def make_report(env, kind='NORMAL', save_scores=True, **kwargs):
comment = result.get('result_string', '')
if comment.lower() in ['ok', 'time limit exceeded']: # Annoying
comment = ''
test_report.comment = Truncator(comment).chars(
TestReport._meta.get_field('comment').max_length
)
max_comment_length = TestReport._meta.get_field('comment').max_length
test_report.comment = (comment[:max_comment_length - 1] + '…') if len(comment) > max_comment_length else comment
if env.get('save_outputs', False):
test_report.output_file = filetracker_to_django_file(result['out_file'])
test_report.save()
Expand Down
5 changes: 2 additions & 3 deletions oioioi/testrun/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ def make_report(env, **kwargs):

testrun_report = TestRunReport(submission_report=submission_report)
testrun_report.status = env['status']
testrun_report.comment = Truncator(comment).chars(
TestRunReport._meta.get_field('comment').max_length
)
max_comment_length = TestRunReport._meta.get_field('comment').max_length
testrun_report.comment = (comment[:max_comment_length - 1] + '…') if len(comment) > max_comment_length else comment
testrun_report.time_used = test_result['time_used']
testrun_report.test_time_limit = test.get('exec_time_limit')
testrun_report.output_file = filetracker_to_django_file(test_result['out_file'])
Expand Down

0 comments on commit f901567

Please sign in to comment.