Commit 8cad8e50 by David Ormsbee

Lower the number of SQL operations to fetch the latest score for

a submission from 3 to 1.
parent f30a74bb
......@@ -381,14 +381,11 @@ def get_scores(course_id, student_id):
def get_latest_score_for_submission(submission_uuid):
try:
submission = Submission.objects.get(uuid=submission_uuid)
score = Score.objects.filter(submission=submission).order_by("-id")[0]
score = Score.objects.filter(
submission__uuid=submission_uuid
).order_by("-id").select_related("submission")[0]
except IndexError:
return None
except Submission.DoesNotExist:
raise SubmissionNotFoundError(
u"No submission matching uuid {}".format(submission_uuid)
)
return ScoreSerializer(score).data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment