From 026a0857f96296f9aff2fd1232014264ff904d4f Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Wed, 8 May 2024 13:49:54 +0200 Subject: [PATCH] fix code review suggestions --- .../tum/in/www1/artemis/service/metrics/MetricsService.java | 4 ++-- .../java/de/tum/in/www1/artemis/web/rest/MetricsResource.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/tum/in/www1/artemis/service/metrics/MetricsService.java b/src/main/java/de/tum/in/www1/artemis/service/metrics/MetricsService.java index 3428ca268e0b..06154eae5ae1 100644 --- a/src/main/java/de/tum/in/www1/artemis/service/metrics/MetricsService.java +++ b/src/main/java/de/tum/in/www1/artemis/service/metrics/MetricsService.java @@ -67,10 +67,10 @@ public ExerciseStudentMetricsDTO getStudentExerciseMetrics(long userId, long cou final var averageScore = exerciseMetricsRepository.findAverageScore(exerciseIds); final var averageScoreMap = averageScore.stream().collect(toMap(ScoreDTO::exerciseId, ScoreDTO::score)); - final var latestSubmissionOfUser = exerciseMetricsRepository.findLatestSubmissionsForUser(exerciseIds, userId); + final var latestSubmissionOfUser = exerciseMetricsRepository.findLatestSubmissionDatesForUser(exerciseIds, userId); final var latestSubmissionMap = latestSubmissionOfUser.stream().collect(toMap(ResourceTimestampDTO::id, ResourceTimestampDTO::timestamp)); - final var latestSubmissions = exerciseMetricsRepository.findLatestSubmissions(exerciseIds); + final var latestSubmissions = exerciseMetricsRepository.findLatestSubmissionDates(exerciseIds); final ToDoubleFunction relativeTime = dto -> toRelativeTime(exerciseInfoMap.get(dto.id()).start(), exerciseInfoMap.get(dto.id()).due(), dto.timestamp()); final var averageLatestSubmissionMap = latestSubmissions.stream().collect(groupingBy(ResourceTimestampDTO::id, averagingDouble(relativeTime))); diff --git a/src/main/java/de/tum/in/www1/artemis/web/rest/MetricsResource.java b/src/main/java/de/tum/in/www1/artemis/web/rest/MetricsResource.java index 1323e71bceb2..e29bb6197e47 100644 --- a/src/main/java/de/tum/in/www1/artemis/web/rest/MetricsResource.java +++ b/src/main/java/de/tum/in/www1/artemis/web/rest/MetricsResource.java @@ -41,7 +41,7 @@ public MetricsResource(MetricsService metricsService, UserRepository userReposit @GetMapping("course/{courseId}/student") @EnforceAtLeastStudentInCourse public ResponseEntity getCourseMetricsForUser(@PathVariable long courseId) { - final var userId = userRepository.getUserId(); // won't throw exception since EnforceRoleInResource checks existence of user + final var userId = userRepository.getUserIdElseThrow(); // won't throw exception since EnforceRoleInResource checks existence of user log.debug("REST request to get the metrics for the user with id {} in the course with id {}", userId, courseId); final var studentMetrics = metricsService.getStudentCourseMetrics(userId, courseId); return ResponseEntity.ok(studentMetrics);