Skip to content

Conversation

@gunsight1
Copy link
Collaborator

@gunsight1 gunsight1 commented Mar 22, 2024

💡 Motivation and Context

여기에 왜 이 PR이 필요했는지, PR을 통해 무엇이 바뀌는지에 대해서 설명해 주세요


  • 게시판 등록, 수정, 조회시 첨부파일 정보도 같이 오도록 수정하였습니다.
  • 목록조회시 jvm Xms 256mb, Xmx 512mb 환경에서 초기 조회 10회 평균 기존 700ms 를
    쿼리 수정하여 500ms -> slice 적용하여 400ms로 단축하였습니다.
  • 첨부파일 정보는 적용시 프론트엔드 개발자와 협의하에 어떠한 정보를 보낼지 정리가 되면 그때 변경하도록 하겠습니다.

스크린샷 2024-03-22 162914
첨부파일 저장

스크린샷 2024-03-22 162530
첨부파일 조회

스크린샷 2024-03-19 121211
스크린샷 2024-03-19 121253
스크린샷 2024-03-19 121301

JOIN절이 2중으로 걸려 딜레이 발생하여 한번만 조인되도록 수정하였습니다.

스크린샷 2024-03-19 121516
스크린샷 2024-03-19 121604 Page 조회시 500ms
스크린샷 2024-03-19 123254 Slice로 변경하여 400ms

🔨 Modified

여기에 무엇이 크게 바뀌었는지 설명해 주세요

  • 여기에 세부 변경사항을 설명해주세요

🌟 More

  • 여기에 PR 이후 추가로 해야 할 일에 대해서 설명해 주세요

  • 테스트코드는 발표후에 시간날 때 천천히 하는것으로....

  • API버저닝은 url을 쓰지말고 API헤더를 추가하여 같은 호출Mapping을 쓰되 버전마다 enum을 통해 매핑하여
    알맞는 method를 타게끔 적용하고 싶었는데 적용이 쉽지않아 일단은 보류하였습니다.
    이는 전략(Strategy) 패턴과 유사성을 가지고 있습니다.

image
url 버저닝


📋 커밋 전 체크리스트

  • 추가/변경에 대한 단위 테스트를 완료하였습니다.
  • 컨벤션에 맞게 작성하였습니다.

🤟🏻 PR로 완료된 이슈

closes #

@gunsight1 gunsight1 added 🖥️ BackEnd 서버 관련 💡 Feature 새로운 기능 추가, 혹은 구현 🔨 Refactor 이 코드는 아주 약간 더 클린코드에 가까워졌습니다... labels Mar 22, 2024
@gunsight1 gunsight1 self-assigned this Mar 22, 2024
Copy link
Collaborator

@HyunJunSon HyunJunSon left a comment

Choose a reason for hiding this comment

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

LGTM

BBSDto result = BBSDto.from(entity, fileRepository.findByReferenceTypeAndReferenceNo(REFERENCE_TYPE, entity.getBbsNo()));

return BBSDto.from(bbsRepository.findOneByBbsNo(bbsNo));
return result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

바로 리턴 하셔도 괜찮을거 같습니다~

Copy link
Collaborator

@chan99k chan99k left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 LGTM

Comment on lines +10 to +11
Page<BBSListDto> getBBSWithConditionByPage(String type, String keyword, Pageable pageable);
Slice<BBSListDto> getBBSWithConditionBySlice(String type, String keyword, Pageable pageable);
Copy link
Collaborator

Choose a reason for hiding this comment

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

페이지를 반환하는 메서드와 슬라이스를 반환하는 메서드를 둘 다 만들어 두는 점 좋은 것 같습니다.

Copy link
Collaborator

@linglong67 linglong67 left a comment

Choose a reason for hiding this comment

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

확인했습니다
LGTM!

Comment on lines +52 to +77
@Override
public Slice<BBSListDto> getBBSWithConditionBySlice(String type, String keyword, Pageable pageable) {

Predicate finalPredicate = bBS.isVisible.eq(true)
.and(bBS.type.eq(BBSType.valueOf(type).name()));

List<BBSListDto> bbs = getBBSListWithMember().
where(
finalPredicate,
keywordContains(keyword)
)
.orderBy(bBS.createdAt.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();

boolean hasNext = false;
int pageSize = pageable.getPageSize();
if(bbs.size() > pageSize){
bbs.remove(pageSize);
hasNext = true;
}

return new SliceImpl<>(bbs, pageable, hasNext);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Slice 적용 시 참고하겠습니다~

Comment on lines -64 to +88
bBS.member.memberNo,
bBS.member.id
member.memberNo,
member.id
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분에서 성능 개선이 있었군요!

}

public static BBSDto from(BBS entity){
public static BBSDto from(BBS entity, List<File> byReferenceTypeAndReferenceNo){
Copy link
Collaborator

Choose a reason for hiding this comment

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

byReferenceTypeAndReferenceNo 대신에 좀 더 '파일 리스트'인 게 드러나는 변수명이 좋지 않을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🖥️ BackEnd 서버 관련 💡 Feature 새로운 기능 추가, 혹은 구현 🔨 Refactor 이 코드는 아주 약간 더 클린코드에 가까워졌습니다...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants