diff --git a/src/main/java/de/tum/in/www1/artemis/repository/UserRepository.java b/src/main/java/de/tum/in/www1/artemis/repository/UserRepository.java index 6dea854f638f..dfcb9c91ff32 100644 --- a/src/main/java/de/tum/in/www1/artemis/repository/UserRepository.java +++ b/src/main/java/de/tum/in/www1/artemis/repository/UserRepository.java @@ -624,7 +624,7 @@ default User getUser() { * * @return the user id of the currently logged-in user */ - default long getUserId() { + default long getUserIdElseThrow() { String currentUserLogin = getCurrentUserLogin(); Optional userId = findIdByLogin(currentUserLogin); return userId.orElseThrow(() -> new EntityNotFoundException("User: " + currentUserLogin)); diff --git a/src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java b/src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java index 60628ba55b1c..cbcc79fc918e 100644 --- a/src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java +++ b/src/main/java/de/tum/in/www1/artemis/repository/metrics/ExerciseMetricsRepository.java @@ -45,11 +45,11 @@ public interface ExerciseMetricsRepository extends JpaRepository Set findAverageScore(@Param("exerciseIds") Set exerciseIds); /** - * Get the latest submissions for a user in a set of exercises. + * Get the latest submission dates for a user in a set of exercises. * * @param exerciseIds the ids of the exercises * @param userId the id of the user - * @return the latest submissions for the user in the exercises + * @return the latest submission dates for the user in the exercises */ @Query(""" SELECT new de.tum.in.www1.artemis.web.rest.dto.metrics.ResourceTimestampDTO(e.id, s.submissionDate) @@ -67,21 +67,19 @@ SELECT MAX(s2.submissionDate) ) AND (p.student.id = :userId OR u.id = :userId) """) - Set findLatestSubmissionsForUser(@Param("exerciseIds") Set exerciseIds, @Param("userId") long userId); + Set findLatestSubmissionDatesForUser(@Param("exerciseIds") Set exerciseIds, @Param("userId") long userId); /** - * Get the latest submissions for a set of users in a set of exercises. + * Get the latest submission dates for a set of exercises. * * @param exerciseIds the ids of the exercises - * @return the latest submissions for the user in the exercises + * @return the latest submission dates for the exercises */ @Query(""" SELECT new de.tum.in.www1.artemis.web.rest.dto.metrics.ResourceTimestampDTO(e.id, s.submissionDate) FROM Submission s LEFT JOIN StudentParticipation p ON s.participation.id = p.id LEFT JOIN p.exercise e - LEFT JOIN p.team t - LEFT JOIN t.students u WHERE e.id IN :exerciseIds AND s.submissionDate = ( SELECT MAX(s2.submissionDate) @@ -90,7 +88,7 @@ SELECT MAX(s2.submissionDate) AND s2.submitted = TRUE ) """) - Set findLatestSubmissions(@Param("exerciseIds") Set exerciseIds); + Set findLatestSubmissionDates(@Param("exerciseIds") Set exerciseIds); /** * Get the submission timestamps for a user in a set of exercises.