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

fix: 타임라인 커서 기준 memoryPK -> recordAt로 변경 #103

Merged
merged 14 commits into from
Jul 25, 2024

Conversation

penrose15
Copy link
Collaborator

@penrose15 penrose15 commented Jul 24, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • cursor 기준이 memoryPK 였음
  • 그러나 수영 기록을 과거의 날짜로도 작성이 가능하여 memoryPK가 recordAt와 비례관계가 되지 않음
  • 이로 인해 최초 최신순 조회 이후 cursorId(memoryPK)를 파라미터로 추가할 경우 cursorId(memoryPK) 의 recordAt 바로 이전의 memory 가 조회되지 않음
  • cursor 기준을 recordAt로 변경하여 문제 해결 (memoryPK를 파라미터로 받으나 내부에서 memoryPK로 memory 를 찾아 해당 memory의 recordAt를 기준으로 삼음)
  • 자세한 사항은 이슈 참고

📝 참고사항

  • 결과

처음 최신순 조회 결과
fix1
fix2

cursorId를 파라미터로 추가한 후, 조회
fix3
fix4

Copy link

github-actions bot commented Jul 24, 2024

Test Results

24 tests   24 ✅  1s ⏱️
 7 suites   0 💤
 7 files     0 ❌

Results for commit 41a30ff.

♻️ This comment has been updated with latest results.

Copy link
Member

@its-sky its-sky left a comment

Choose a reason for hiding this comment

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

수고하셨습니다


@Getter
@NoArgsConstructor
public class Timeline<T extends Memory> {
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
Collaborator Author

Choose a reason for hiding this comment

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

다시 생각해보니 굳이 제네릭으로 구현할 필요가 없네요 수정했습니다.

Slice<Memory> findPrevMemoryByMemberId(
Long memberId, Long cursorId, Pageable pageable, LocalDate recordAt);
Timeline<Memory> findPrevMemoryByMemberId(
Long memberId, LocalDate cursorRecordAt, LocalDate recordAt);
Copy link
Member

Choose a reason for hiding this comment

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

프론트엔드에서 마지막 기록의 날짜를 넘겨주면 되는건데 id로 조회하고 해당 기록의 날짜를 뽑아서 굳이 넘기는 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

프론트에게 혼란을 줄 수 있을거 같아서 파라미터를 그래도 사용하려 했는데 그냥 한 번 더 이야기 하면 될 문제네요 수정 했습니다.

@@ -47,7 +47,7 @@ public ApiResponse<MemoryResponse> update(

@GetMapping("/timeline")
public ApiResponse<?> timeline(
@LoginMember Long memberId, @ModelAttribute TimelineRequestDto timelineRequestDto) {
@LoginMember Long memberId, TimelineRequestDto timelineRequestDto) {
Copy link
Member

Choose a reason for hiding this comment

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

여긴 왜 @ModelAttribute를 제거하셨죠?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

확인 결과 ModelAttribute 없이도 동작하여 삭제하였습니다.

@@ -47,7 +47,7 @@ public ApiResponse<MemoryResponse> update(

@GetMapping("/timeline")
public ApiResponse<?> timeline(
@LoginMember Long memberId, @ModelAttribute TimelineRequestDto timelineRequestDto) {
@LoginMember Long memberId, TimelineRequestDto timelineRequestDto) {
Copy link
Member

Choose a reason for hiding this comment

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

여긴 왜 @ModelAttribute 를 제거하셨나요?

memoryRepository
.findById(timeline.getCursorId())
.orElseThrow(() -> new NotFoundException(MemoryErrorType.NOT_FOUND));
cursorRecordAt = memory.getRecordAt();
Copy link
Member

Choose a reason for hiding this comment

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

왜 굳이 id로 넘겨서 recordAt을 조회하는 쿼리 한번을 써야 할까요? 그냥 프론트엔드에서 recordAt 데이터를 넘기면 될거 같다고 생각합니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정했습니다.

Copy link
Member

@its-sky its-sky left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~

@penrose15 penrose15 merged commit 028126c into develop Jul 25, 2024
2 checks passed
@its-sky its-sky deleted the fix/101-change-timeline-cursor branch July 30, 2024 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants