Skip to content

feat : 반례게시판 이슈 해결 및 정렬을 위한 분기 param 추가 - #404

Merged
junggyo1020 merged 6 commits into
developfrom
BE-50
Oct 26, 2025
Merged

junggyo1020 merged 6 commits into
developfrom
BE-50

Conversation

@junggyo1020

Copy link
Copy Markdown
Contributor

📌 Related Issue

BE-50

🚀 Description

  • 반례 게시판의 주요 이슈를 해결하고, 사용자 편의를 위해 정렬 기능을 추가했습니다.
image

  • 최신순 정렬 버그 수정: EdgeCase 엔티티 생성 시 createdAt이 누락되어 최신순 정렬이 동작하지 않던 문제를 해결했습니다. (생성자에 LocalDateTime.now() 할당)
image

  • 좋아요 카운트 버그 수정: 반례 좋아요 토글 시(togleEdgeCaseLike) EdgeCase 엔티티의 likeCount가 갱신되지 않던 버그를 수정했습니다.
image

  • 정렬 기능 파라미터 추가: 반례 리스트 조회 API(GET /api/edge-case/list)에 sort 파라미터를 추가했습니다.

  • RECENT (최신순, 기본값), LIKE (좋아요순), OLD (오래된순) 3가지 옵션으로 분기하도록 Enum 클래스를 추가했습니다!

📢 Review Point

  • 이슈가 발생한 부분이 있어 클라측에서 요청한 급한 안건을 먼저 해결하게 되었습니다..! (원래 상혁님 테스크인데 본의 아니게 제가 처리하게 된 점 죄송합니다 ㅠㅠ)

  • likeCount 관리를 위해 EdgeCase 엔티티에 컬럼을 두고, 토글 시마다 UPDATE 쿼리가 발생하도록 했습니다. 이 방식이 괜찮은지, 아니면 COUNT 쿼리를 사용하는 방식이 나을지 의견 주시면 감사하겠습니다.

📚Etc (선택)

테스트 코드 결과

image

@junggyo1020 junggyo1020 self-assigned this Oct 19, 2025
@junggyo1020 junggyo1020 added the new-feature 기능 추가 label Oct 19, 2025
@linear

linear Bot commented Oct 19, 2025

Copy link
Copy Markdown

@channeltalk

channeltalk Bot commented Oct 19, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 19, 2025 •

Copy link
Copy Markdown

Test Results

 27 files   27 suites   7s ⏱️
355 tests 355 ✅ 0 💤 0 ❌
357 runs  357 ✅ 0 💤 0 ❌

Results for commit af59698.

♻️ This comment has been updated with latest results.

@sh0723

sh0723 commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

제가 해야 할 부분들인데, 시험기간이라 보질 못해서 대신해주셨네요.. 감사드려요..!
고생하셨습니다 :)

@rladmstn rladmstn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

고생하셨습니다!!
문제는 딱히 없어보여요!
본문에 올려주신 count vs 필드 에 대한 답변이랑 코멘트만 달아두었습니담

Comment on lines +60 to +73
if (problemNumber == null) {
switch (sort) {
case LIKE:
edgeCaseList = edgeCaseRepository.findAllByOrderByLikeCountDesc();
break;
case OLD:
edgeCaseList = edgeCaseRepository.findAllByOrderByCreatedAtAsc();
break;
case RECENT:
default:
edgeCaseList = edgeCaseRepository.findAllByOrderByCreatedAtDesc();
break;
}
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 분기처리들은 QueryDsl 사용해서 동적 쿼리 생성했어도 좋았겠단 생각이 드네요..!
하지만 지금은 기능 구현이 우선이니 넘어갑시다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

이후 리팩토링할때 참고하도록 하겠습니다 :) 제안 감사드려요 ㅎㅎ

Comment on lines +62 to +70
public void increaseLikeCount() {
this.likeCount++;
}

public void decreaseLikeCount() {
if (this.likeCount > 0) {
this.likeCount--;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저는 count보다 현재 방식 좋은 것 같습니다!
동시성 문제가 좀 우려되는 방식이긴 하지만, 이건 나중에 발생하면 @Modifying + update 쿼리로 해결할 수 있을 것 같아요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

동시성 문제가 터지는 트래픽이 발생하는 경우에 도입을 한번 고려해보면 좋을 것 같아요 ㅎㅎ
좋은 의견 감사드립니다 :)

@s-hwan s-hwan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저도 지금 방식이 좋은 것 같아요 ! 고생하셨습니다

junggyo1020 and others added 6 commits October 26, 2025 23:48
- EdgeCase 엔티티 생성자에 createdAt 자동 할당 로직 추가 (최신순 정렬 버그 해결)
- EdgeCase 엔티티에 likeCount 증감 헬퍼 메서드 (increase/decrease) 추가
- 정렬 옵션을 관리하기 위한 EdgeCaseSortType ENUM (RECENT, LIKE, OLD) 생성
- EdgeCaseRepository에 좋아요순(LikeCountDesc), 오래된순(CreatedAtAsc) 정렬 메서드 추가
- EdgeCaseController의 getEdgeCaseList에 `sort` 파라미터 추가 (기본값 RECENT)
- EdgeCaseService의 getEdgeCaseList가 `sort` 값에 따라 분기 처리하도록 로직 구현
- setUp: 정렬 순서(createdAt, likeCount) 검증을 위한 테스트 데이터 상세 설정
- `createEdgeCase` 테스트: createdAt 할당 여부 검증 추가
- `togleEdgeCaseLike` 테스트: likeCount 증감 여부 검증 로직 추가
- `getEdgeCaseList` 테스트: RECENT, LIKE, OLD 각 정렬 옵션별 조회 결과 순서 검증 케이스 추가
@junggyo1020
junggyo1020 merged commit 5c7fd81 into develop Oct 26, 2025
2 checks passed
hwangjokim pushed a commit that referenced this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants