diff --git a/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestRepository.java b/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestRepository.java index b5575bbe..503721a7 100644 --- a/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestRepository.java +++ b/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestRepository.java @@ -18,7 +18,9 @@ Optional findByRepositoryRepositoryIdAndHeadRefNameAndState(Long re String headRefName, Issue.State state); - List findByRepositoryRepositoryId(Long repositoryId); + List findAllByOrderByUpdatedAtDesc(); + + List findByRepositoryRepositoryIdOrderByUpdatedAtDesc(Long repositoryId); Optional findByRepositoryRepositoryIdAndNumber(Long repositoryId, Integer number); } diff --git a/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestService.java b/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestService.java index 2df98cb1..a076810d 100644 --- a/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestService.java +++ b/server/application-server/src/main/java/de/tum/cit/aet/helios/pullrequest/PullRequestService.java @@ -17,7 +17,7 @@ public PullRequestService(PullRequestRepository pullRequestRepository) { } public List getAllPullRequests() { - return pullRequestRepository.findAll().stream() + return pullRequestRepository.findAllByOrderByUpdatedAtDesc().stream() .map(PullRequestBaseInfoDto::fromPullRequest) .collect(Collectors.toList()); } @@ -27,7 +27,8 @@ public Optional getPullRequestById(Long id) { } public List getPullRequestByRepositoryId(Long repositoryId) { - return pullRequestRepository.findByRepositoryRepositoryId(repositoryId).stream() + return pullRequestRepository.findByRepositoryRepositoryIdOrderByUpdatedAtDesc(repositoryId) + .stream() .map(PullRequestInfoDto::fromPullRequest) .collect(Collectors.toList()); }