Skip to content

Commit

Permalink
fix code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAnzinger committed May 8, 2024
1 parent 324910b commit 026a085
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResourceTimestampDTO> 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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public MetricsResource(MetricsService metricsService, UserRepository userReposit
@GetMapping("course/{courseId}/student")
@EnforceAtLeastStudentInCourse
public ResponseEntity<StudentMetricsDTO> 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);
Expand Down

0 comments on commit 026a085

Please sign in to comment.