Skip to content

Commit

Permalink
[extract] improve query
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-christl committed Jan 26, 2024
1 parent 1c9329b commit 807a92e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ public interface ResultRepository extends JpaRepository<Result, Long> {
FROM Result r
LEFT JOIN FETCH r.feedbacks f
LEFT JOIN FETCH f.testCase
LEFT JOIN TREAT (r.participation AS StudentParticipation) sp
WHERE r.completionDate =
(SELECT max(rr.completionDate) FROM Result rr
JOIN TREAT (rr.participation AS StudentParticipation) ssp
WHERE rr.assessmentType = 'AUTOMATIC'
AND rr.participation.exercise.id = :exerciseId
AND TYPE(rr.participation) = StudentParticipation
AND rr.participation.student.id = r.participation.student.id
AND ssp.student = sp.student
)
AND r.participation.exercise.id = :exerciseId
AND r.participation.student.id IS NOT NULL
AND sp.student.id IS NOT NULL
ORDER BY r.completionDate ASC
""")
List<Result> findLatestAutomaticResultsWithEagerFeedbacksForExercise(@Param("exerciseId") Long exerciseId);
Expand Down

0 comments on commit 807a92e

Please sign in to comment.