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: lastViewedId default 값 설정 #46

Conversation

Combi153
Copy link
Contributor

@Combi153 Combi153 commented Feb 3, 2024

📌 관련 이슈

📁 작업 설명

  • lastViewedId가 default 값으로 들어온 경우 null 로 설정하도록 로직을 짰습니다.

val adjustedLimit = if (limit > LIMIT_CEILING) LIMIT_CEILING else limit
return ProductPaging(lastViewedId, adjustedLimit + PADDING_FOR_PAGING)
return ProductPaging(adjustedLastViewedId, adjustedLimit + PADDING_FOR_PAGING)
Copy link
Contributor

Choose a reason for hiding this comment

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

늦은 리뷰인데...ㅋㅋ...
혹시 PADDGING_FOR_PAGING이 필요한 이유 설명 부탁드려도 될까요.............ㅎㅎ.......... 🙇‍♀️🙇‍♀️🙇‍♀️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

클라이언트가 limit으로 20개를 요청했다고 가정할게요.

서버는 클라이언트에게 20개의 데이터를 보내면서 다음 페이지가 존재하는지 여부를 함께 응답해요. 만약 다음 페이지가 존재하는지 여부를 알려주지 않는다면, 클라이언트 입장에서는 데이터가 반환되지 않는 것이 데이터가 더 이상 없기 때문인지, 아니면 서버에 문제가 생겼기 때문이지 파악할 수 없기 때문이에요.

이때 다음 페이지가 존재하는지 알기 위해 저는 limit 20 에서 padding 1을 더해서, 총 21개의 데이터를 DB에서 읽어오도록 설정했어요.

만약 DB에서 꺼낸 데이터가 21개라면 다음 페이지가 있다고 판단하면 되고 20개 이하라면 다음 페이지가 없다고 판단하면 되니까요. 그때 사용되는 값이 PADDING_FOR_PAGING 입니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

최고!

Copy link
Member

@TaeyeonRoyce TaeyeonRoyce left a comment

Choose a reason for hiding this comment

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

👍

@Combi153 Combi153 force-pushed the 45-refactor-페이지네이션-lastviewedid-default-값-설정 branch from 00b5b59 to 32ce9ae Compare February 6, 2024 01:31
Copy link

github-actions bot commented Feb 6, 2024

Test Results

 20 files  ±0   20 suites  ±0   6s ⏱️ ±0s
 71 tests ±0   71 ✅ ±0  0 💤 ±0  0 ❌ ±0 
102 runs  ±0  102 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 32ce9ae. ± Comparison against base commit 6ce6c63.

@Combi153 Combi153 merged commit e4e3448 into develop Feb 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: 페이지네이션 lastViewedId default 값 설정
3 participants