Skip to content

[refactor] 목록 조회 시 최신 생성순으로 정렬되도록 기준 수정(#322)#327

Merged
exjuu merged 1 commit intoKernel360:devfrom
exjuu:feature/#322
Jul 3, 2025
Merged

[refactor] 목록 조회 시 최신 생성순으로 정렬되도록 기준 수정(#322)#327
exjuu merged 1 commit intoKernel360:devfrom
exjuu:feature/#322

Conversation

@exjuu
Copy link
Collaborator

@exjuu exjuu commented Jul 3, 2025

📌 개요

  • 도메인 전반의 목록 조회 정렬 기준을 id 기준에서 createdAt 기준으로 변경하여, 최신 생성된 항목이 상단에 표시되도록 개선

🛠️ 변경 사항

  • member, project, projectCheckList, company 등 목록 조회 쿼리에 .orderBy(createdAt.desc()) 추가
  • project.id.in(...) 조회 시에도 createdAt.desc() 기준 정렬 추가
  • 기존 id.desc() 또는 정렬 없음 상태였던 쿼리들을 명시적 정렬로 변경

✅ 주요 체크 포인트

  • 정렬 변경으로 인한 기존 UI 정렬 기대값과의 차이 여부
  • createdAt 필드 누락 또는 null 가능성 존재 여부
  • 정렬 기준 변경이 페이징에 미치는 영향 (특히 이전 페이지/다음 페이지 결과)

🔁 테스트 결과

  • 프로젝트, 멤버, 체크리스트 등 주요 목록 API 호출 후 프론트에서 정렬 순서 확인
  • 각 목록에서 최신 항목이 가장 상단에 표시되는지 확인
  • 기존 기능 정상 동작 유지 확인

🔗 연관된 이슈

  • 없음

📑 레퍼런스

  • 없음

@exjuu exjuu merged commit 62baeae into Kernel360:dev Jul 3, 2025
1 check passed
@leeesooha leeesooha requested a review from Copilot July 17, 2025 10:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to createdAt.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();
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants