-
Notifications
You must be signed in to change notification settings - Fork 0
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
The head ref may contain hidden characters: "45-refactor-\uD398\uC774\uC9C0\uB124\uC774\uC158-lastviewedid-default-\uAC12-\uC124\uC815"
Conversation
val adjustedLimit = if (limit > LIMIT_CEILING) LIMIT_CEILING else limit | ||
return ProductPaging(lastViewedId, adjustedLimit + PADDING_FOR_PAGING) | ||
return ProductPaging(adjustedLastViewedId, adjustedLimit + PADDING_FOR_PAGING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
늦은 리뷰인데...ㅋㅋ...
혹시 PADDGING_FOR_PAGING이 필요한 이유 설명 부탁드려도 될까요.............ㅎㅎ.......... 🙇♀️🙇♀️🙇♀️
There was a problem hiding this comment.
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 입니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최고!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
00b5b59
to
32ce9ae
Compare
📌 관련 이슈
📁 작업 설명