Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : 메인페이지 공연 정렬 순서 변경 #567

Merged
merged 2 commits into from
Jul 24, 2023

Conversation

gengminy
Copy link
Member

개요

작업사항

  • 메인페이지 정렬순서 변경
  • 진행중인 공연 : 등록일 순서 (by createdAt)
  • 지난 공연 : 공연일 순서 (by startAt)

변경로직

  • domain/event

@gengminy gengminy added For: API [이슈 대상] 외부 API Type: Refactor [이슈 목적] 프로덕션 코드 리팩토링 labels Jul 22, 2023
@gengminy gengminy self-assigned this Jul 22, 2023
Copy link
Member

@ImNM ImNM left a comment

Choose a reason for hiding this comment

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

spotless 한번 돌려주셔유!

Comment on lines +58 to +59
.where(eqStatusOpen().and(nameContains(keyword)))
.orderBy(createdAtAsc())
Copy link
Member

Choose a reason for hiding this comment

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

and로 묶어주는것도 좋네용

Comment on lines +64 to +67
final long remainingSize = Math.max(pageable.getPageSize() - openEvents.size(), 0);
if (remainingSize > 0) {
openEvents.addAll(queryClosedEventsByKeywordAndSize(keyword, pageable, remainingSize));
}
Copy link
Member

Choose a reason for hiding this comment

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

오 이 로직은 무슨역할이죵

Copy link
Member Author

@gengminy gengminy Jul 24, 2023

Choose a reason for hiding this comment

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

정렬 순서가 앞 뒤로 달라서 어쩔 수 없이 쿼리를 두번 쏴서 페이징하는데
OPEN 상태인 공연 개수 결과를 세서 pageSize 보다 작으면
pageSize - OPEN 공연수 계산해서 나머지 개수만큼 limit 해서 CLOSED 공연을 가져오는 로직입니다

근데 이미 OPEN 공연을 pageSize 만큼 전부 가져왔을 수도 있으니
그 때는 CLOSED 공연 가져오는 쿼리 안날라가도록 조건문으로 최적화 했습니다~

Copy link
Member

@sanbonai06 sanbonai06 left a comment

Choose a reason for hiding this comment

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

LGTM
근데 찬진이 말대로 spotless 깨진거 같에용

@sonarcloud
Copy link

sonarcloud bot commented Jul 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@gengminy gengminy merged commit b69fdc5 into dev Jul 24, 2023
3 checks passed
@gengminy gengminy deleted the refactor/566-event-order branch July 24, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: API [이슈 대상] 외부 API Type: Refactor [이슈 목적] 프로덕션 코드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🔨[refactor] 메인 페이지 지난공연 정렬 조건
3 participants