[refactor] 목록 조회 시 최신 생성순으로 정렬되도록 기준 수정(#322)#327
Merged
exjuu merged 1 commit intoKernel360:devfrom Jul 3, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the sorting criteria for list queries across multiple domains, changing from id-based sorting to createdAt-based sorting to display the most recently created items first.
- Changed sorting from
id.desc()or no explicit ordering tocreatedAt.desc()across multiple repositories - Added explicit ordering to queries that previously had no sorting criteria
- Removed manual sorting logic in service layer that is now handled at the repository level
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| QueryDslProjectCheckListRepository.java | Added createdAt.desc() ordering to project checklist queries |
| QueryDslProjectRepository.java | Added createdAt.desc() ordering to project queries including pagination and ID-based lookups |
| QueryDslMemberRepository.java | Changed from id.desc() to createdAt.desc() ordering for member search queries |
| QueryDslCompanyRepository.java | Added createdAt.desc() ordering to company search queries |
| ProjectService.java | Removed manual sorting by ID that is now handled at repository level |
Comment on lines
190
to
194
| return queryFactory | ||
| .selectFrom(project) | ||
| .where(project.id.in(projectIds)) | ||
| .orderBy(project.createdAt.desc()) | ||
| .fetch(); |
There was a problem hiding this comment.
Adding ordering to the findProjectsByIds method may produce unexpected results for callers who expect projects to be returned in the same order as the input projectIds list. Consider whether maintaining input order is important for this method's use cases.
Suggested change
| return queryFactory | |
| .selectFrom(project) | |
| .where(project.id.in(projectIds)) | |
| .orderBy(project.createdAt.desc()) | |
| .fetch(); | |
| List<Project> projects = queryFactory | |
| .selectFrom(project) | |
| .where(project.id.in(projectIds)) | |
| .fetch(); | |
| // Reorder projects to match the order of projectIds | |
| return projectIds.stream() | |
| .map(id -> projects.stream().filter(p -> p.getId().equals(id)).findFirst().orElse(null)) | |
| .filter(p -> p != null) | |
| .toList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 개요
id기준에서createdAt기준으로 변경하여, 최신 생성된 항목이 상단에 표시되도록 개선🛠️ 변경 사항
member,project,projectCheckList,company등 목록 조회 쿼리에.orderBy(createdAt.desc())추가project.id.in(...)조회 시에도createdAt.desc()기준 정렬 추가id.desc()또는 정렬 없음 상태였던 쿼리들을 명시적 정렬로 변경✅ 주요 체크 포인트
🔁 테스트 결과
🔗 연관된 이슈
📑 레퍼런스