Optimize contest ranked submission (DMOJ)

This commit is contained in:
cuom1999 2023-03-06 22:56:31 -06:00
parent 8a6288f8e6
commit d5b21935ae
2 changed files with 6 additions and 5 deletions

View file

@ -17,10 +17,9 @@ class RankedSubmissions(ProblemSubmissions):
def get_queryset(self): def get_queryset(self):
if self.in_contest: if self.in_contest:
contest_join = """INNER JOIN judge_contestsubmission AS cs ON (sub.id = cs.submission_id) contest_join = "INNER JOIN judge_contestsubmission AS cs ON (sub.id = cs.submission_id)"
INNER JOIN judge_contestparticipation AS cp ON (cs.participation_id = cp.id)"""
points = "cs.points" points = "cs.points"
constraint = "AND cp.contest_id = %s" constraint = " AND sub.contest_object_id = %s"
else: else:
contest_join = "" contest_join = ""
points = "sub.points" points = "sub.points"
@ -46,8 +45,8 @@ class RankedSubmissions(ProblemSubmissions):
GROUP BY sub.user_id, {points} GROUP BY sub.user_id, {points}
) AS fastest ON (highscore.uid = fastest.uid AND highscore.points = fastest.points) ) AS fastest ON (highscore.uid = fastest.uid AND highscore.points = fastest.points)
STRAIGHT_JOIN judge_submission AS sub STRAIGHT_JOIN judge_submission AS sub
ON (sub.user_id = fastest.uid AND sub.time = fastest.time) {contest_join} ON (sub.user_id = fastest.uid AND sub.time = fastest.time)
WHERE sub.problem_id = %s AND {points} > 0 {constraint} WHERE sub.problem_id = %s {constraint}
GROUP BY sub.user_id GROUP BY sub.user_id
""".format( """.format(
points=points, contest_join=contest_join, constraint=constraint points=points, contest_join=contest_join, constraint=constraint

View file

@ -135,6 +135,8 @@
</div> </div>
<hr> <hr>
{% endif %} {% endif %}
<div style="clear: both"></div>
<br>
{% include "actionbar/list.html" %} {% include "actionbar/list.html" %}
<br> <br>
{% include "comments/list.html" %} {% include "comments/list.html" %}