Skip to content

Commit

Permalink
fix: Get all the PRs in sorted by updatedAt (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
egekocabas authored Jan 19, 2025
1 parent 6e4a006 commit ae17856
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Optional<PullRequest> findByRepositoryRepositoryIdAndHeadRefNameAndState(Long re
String headRefName,
Issue.State state);

List<PullRequest> findByRepositoryRepositoryId(Long repositoryId);
List<PullRequest> findAllByOrderByUpdatedAtDesc();

List<PullRequest> findByRepositoryRepositoryIdOrderByUpdatedAtDesc(Long repositoryId);

Optional<PullRequest> findByRepositoryRepositoryIdAndNumber(Long repositoryId, Integer number);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public PullRequestService(PullRequestRepository pullRequestRepository) {
}

public List<PullRequestBaseInfoDto> getAllPullRequests() {
return pullRequestRepository.findAll().stream()
return pullRequestRepository.findAllByOrderByUpdatedAtDesc().stream()
.map(PullRequestBaseInfoDto::fromPullRequest)
.collect(Collectors.toList());
}
Expand All @@ -27,7 +27,8 @@ public Optional<PullRequestInfoDto> getPullRequestById(Long id) {
}

public List<PullRequestInfoDto> getPullRequestByRepositoryId(Long repositoryId) {
return pullRequestRepository.findByRepositoryRepositoryId(repositoryId).stream()
return pullRequestRepository.findByRepositoryRepositoryIdOrderByUpdatedAtDesc(repositoryId)
.stream()
.map(PullRequestInfoDto::fromPullRequest)
.collect(Collectors.toList());
}
Expand Down

0 comments on commit ae17856

Please sign in to comment.