Skip to content

Commit

Permalink
improve method name, replace do while
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-christl committed Sep 17, 2024
1 parent 1301830 commit d73bbf8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions .idea/runConfigurations/_template__of_Gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.hibernate.Hibernate;
import org.slf4j.Logger;
Expand Down Expand Up @@ -88,17 +89,17 @@ public void cleanup() {
log.error("Exception occurred during cleanupBuildPlansOnContinuousIntegrationServer", ex);
}
try {
cleanupGitRepositoriesOnArtemisServer();
cleanupGitWorkingCopiesOnArtemisServer();
}
catch (Exception ex) {
log.error("Exception occurred during cleanupGitRepositoriesOnArtemisServer", ex);
log.error("Exception occurred during cleanupGitWorkingCopiesOnArtemisServer", ex);
}
}

/**
* cleans up old local git repositories on the Artemis server
*/
public void cleanupGitRepositoriesOnArtemisServer() {
public void cleanupGitWorkingCopiesOnArtemisServer() {
SecurityUtils.setAuthorizationObject();
log.info("Cleanup git repositories on Artemis server");
// we are specifically interested in exercises older than 8 weeks
Expand Down Expand Up @@ -134,12 +135,11 @@ private void cleanStudentParticipationsRepositories(ZonedDateTime earliestDate,
pageable);
log.info("Found {} student participations to clean local student repositories in {} batches.", uriBatch.getTotalElements(), uriBatch.getTotalPages());
if (uriBatch.getTotalElements() > 0) {
do {
uriBatch.forEach(this::deleteLocalRepositoryByUriString);
uriBatch = programmingExerciseStudentParticipationRepository.findRepositoryUrisForGitCleanupByRecentDueDateOrRecentExamEndDate(earliestDate, latestDate,
uriBatch.nextPageable());
}
while (uriBatch.hasNext());
var ignored = Stream.iterate(uriBatch, Page::hasNext, page -> {
page.forEach(this::deleteLocalRepositoryByUriString);
return programmingExerciseStudentParticipationRepository.findRepositoryUrisForGitCleanupByRecentDueDateOrRecentExamEndDate(earliestDate, latestDate,
page.nextPageable());
});
log.info("Finished cleaning local student repositories");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ void automaticCleanupGitRepositories() {
createProgrammingParticipationWithSubmissionAndResult(examExercise, "student3", 100D, ZonedDateTime.now().minusDays(2L), false);
createProgrammingParticipationWithSubmissionAndResult(examExercise, "student4", 80D, ZonedDateTime.now().minusDays(6L), false);

automaticProgrammingExerciseCleanupService.cleanupGitRepositoriesOnArtemisServer();
automaticProgrammingExerciseCleanupService.cleanupGitWorkingCopiesOnArtemisServer();
// Note: at the moment, we cannot easily assert something here, it might be possible to verify mocks on gitService, in case we could define it as SpyBean
}

Expand Down

0 comments on commit d73bbf8

Please sign in to comment.