Skip to content

Commit

Permalink
Filter contest submissions properly in live updates (#1701)
Browse files Browse the repository at this point in the history
Co-authored-by: Quantum <quantum2048@gmail.com>
  • Loading branch information
Ninjaclasher and quantum5 authored May 30, 2021
1 parent 2ad0986 commit aea5fbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions judge/bridge/judge_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def _post_update_submission(self, id, state, done=False):
data = self._submission_cache
else:
self._submission_cache = data = Submission.objects.filter(id=id).values(
'problem__is_public', 'contest_object__key',
'problem__is_public', 'contest_object_id',
'user_id', 'problem_id', 'status', 'language__key',
).get()
self._submission_cache_id = id
Expand All @@ -622,7 +622,7 @@ def _post_update_submission(self, id, state, done=False):
event.post('submissions', {
'type': 'done-submission' if done else 'update-submission',
'state': state, 'id': id,
'contest': data['contest_object__key'],
'contest': data['contest_object_id'],
'user': data['user_id'], 'problem': data['problem_id'],
'status': data['status'], 'language': data['language__key'],
})
1 change: 1 addition & 0 deletions judge/views/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def get_context_data(self, **kwargs):
context = super(SubmissionsListBase, self).get_context_data(**kwargs)
authenticated = self.request.user.is_authenticated
context['dynamic_update'] = False
context['dynamic_contest_id'] = self.in_contest and self.contest.id
context['show_problem'] = self.show_problem
context['completed_problem_ids'] = user_completed_ids(self.request.profile) if authenticated else []
context['editable_problem_ids'] = user_editable_ids(self.request.profile) if authenticated else []
Expand Down
15 changes: 7 additions & 8 deletions templates/submission/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
{% block js_media %}
<script type="text/javascript">
{% if dynamic_update and last_msg %}
{% if request.in_contest %}
window.current_contest = '{{request.participation.contest.key}}';
{% if dynamic_contest_id %}
window.dynamic_contest_id = {{ dynamic_contest_id }};
{% else %}
window.current_contest = null;
window.dynamic_contest_id = null;
{% endif %}
{% if dynamic_user_id %}
window.dynamic_user_id = {{dynamic_user_id}};
window.dynamic_user_id = {{ dynamic_user_id }};
{% else %}
window.dynamic_user_id = null;
{% endif %}
{% if dynamic_problem_id %}
window.dynamic_problem_id = {{dynamic_problem_id}};
window.dynamic_problem_id = {{ dynamic_problem_id }};
{% else %}
window.dynamic_problem_id = null;
{% endif %}
Expand Down Expand Up @@ -212,10 +212,9 @@
var receiver = new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['submissions'], last_msg, function (message) {
if (current_contest && message.contest != current_contest)
return;
if (dynamic_user_id && message.user != dynamic_user_id ||
dynamic_problem_id && message.problem != dynamic_problem_id)
dynamic_problem_id && message.problem != dynamic_problem_id ||
dynamic_contest_id && message.contest != dynamic_contest_id)
return;
if (message.type == 'update-submission') {
if (message.state == 'test-case' && $body.hasClass('window-hidden'))
Expand Down

0 comments on commit aea5fbd

Please # to comment.