Skip to content

Commit

Permalink
Development: Fix server tests related to build log statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
krusche committed Nov 13, 2024
1 parent 1b50466 commit 70ccfc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ default BuildLogStatisticsDTO findAverageBuildLogStatistics(ProgrammingExercise
var studentStatistics = findAverageStudentBuildLogStatistics(exercise);
var exerciseStatistics = findAverageExerciseBuildLogStatistics(exercise.getTemplateParticipation() != null ? exercise.getTemplateParticipation().getId() : null,
exercise.getSolutionParticipation() != null ? exercise.getSolutionParticipation().getId() : null);
// combine both based on the count
// build the average of two values based on the count
var studentCount = studentStatistics.buildCount();
var exerciseCount = exerciseStatistics.buildCount();
return new BuildLogStatisticsDTO(studentCount + exerciseCount,
studentStatistics.agentSetupDuration() * studentCount + exerciseStatistics.agentSetupDuration() * exerciseCount,
studentStatistics.testDuration() * studentCount + exerciseStatistics.testDuration() * exerciseCount,
studentStatistics.scaDuration() * studentCount + exerciseStatistics.scaDuration() * exerciseCount,
studentStatistics.totalJobDuration() * studentCount + exerciseStatistics.totalJobDuration() * exerciseCount,
studentStatistics.dependenciesDownloadedCount() * studentCount + exerciseStatistics.dependenciesDownloadedCount() * exerciseCount);
var count = studentCount + exerciseCount;
return new BuildLogStatisticsDTO(count,
count == 0 ? 0.0 : (studentStatistics.agentSetupDuration() * studentCount + exerciseStatistics.agentSetupDuration() * exerciseCount) / count,
count == 0 ? 0.0 : (studentStatistics.testDuration() * studentCount + exerciseStatistics.testDuration() * exerciseCount) / count,
count == 0 ? 0.0 : (studentStatistics.scaDuration() * studentCount + exerciseStatistics.scaDuration() * exerciseCount) / count,
count == 0 ? 0.0 : (studentStatistics.totalJobDuration() * studentCount + exerciseStatistics.totalJobDuration() * exerciseCount) / count,
count == 0 ? 0.0 : (studentStatistics.dependenciesDownloadedCount() * studentCount + exerciseStatistics.dependenciesDownloadedCount() * exerciseCount) / count);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2630,12 +2630,12 @@ public void buildLogStatistics_noStatistics() throws Exception {
exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig()));
exercise = programmingExerciseRepository.save(exercise);
var statistics = request.get("/api/programming-exercises/" + exercise.getId() + "/build-log-statistics", HttpStatus.OK, BuildLogStatisticsDTO.class);
assertThat(statistics.buildCount()).isZero();
assertThat(statistics.agentSetupDuration()).isNull();
assertThat(statistics.testDuration()).isNull();
assertThat(statistics.scaDuration()).isNull();
assertThat(statistics.totalJobDuration()).isNull();
assertThat(statistics.dependenciesDownloadedCount()).isNull();
assertThat(statistics.buildCount()).isEqualTo(0);
assertThat(statistics.agentSetupDuration()).isEqualTo(0);
assertThat(statistics.testDuration()).isEqualTo(0);
assertThat(statistics.scaDuration()).isEqualTo(0);
assertThat(statistics.totalJobDuration()).isEqualTo(0);
assertThat(statistics.dependenciesDownloadedCount()).isEqualTo(0);
}

// TEST
Expand Down

0 comments on commit 70ccfc3

Please sign in to comment.