Skip to content

Commit

Permalink
Merge branch 'feature/adaptive-learning/add-metrics-service' of https…
Browse files Browse the repository at this point in the history
…://github.com/ls1intum/Artemis into feature/adaptive-learning/add-metrics-service
  • Loading branch information
MaximilianAnzinger committed May 8, 2024
2 parents e0a6637 + de60b0d commit 324910b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> userId = findIdByLogin(currentUserLogin);
return userId.orElseThrow(() -> new EntityNotFoundException("User: " + currentUserLogin));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public interface ExerciseMetricsRepository extends JpaRepository<Exercise, Long>
Set<ScoreDTO> findAverageScore(@Param("exerciseIds") Set<Long> 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)
Expand All @@ -67,21 +67,19 @@ SELECT MAX(s2.submissionDate)
)
AND (p.student.id = :userId OR u.id = :userId)
""")
Set<ResourceTimestampDTO> findLatestSubmissionsForUser(@Param("exerciseIds") Set<Long> exerciseIds, @Param("userId") long userId);
Set<ResourceTimestampDTO> findLatestSubmissionDatesForUser(@Param("exerciseIds") Set<Long> 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)
Expand All @@ -90,7 +88,7 @@ SELECT MAX(s2.submissionDate)
AND s2.submitted = TRUE
)
""")
Set<ResourceTimestampDTO> findLatestSubmissions(@Param("exerciseIds") Set<Long> exerciseIds);
Set<ResourceTimestampDTO> findLatestSubmissionDates(@Param("exerciseIds") Set<Long> exerciseIds);

/**
* Get the submission timestamps for a user in a set of exercises.
Expand Down

0 comments on commit 324910b

Please sign in to comment.