-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FEAT] 커뮤니티 게시글 전체조회 API #345
Conversation
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.
댓글 남겼습니다!
Co-authored-by: Chae Jeong Ah <jokj624@gmail.com>
Co-authored-by: Chae Jeong Ah <jokj624@gmail.com>
Co-authored-by: Chae Jeong Ah <jokj624@gmail.com>
@yubinquitous |
@jokj624 요거 반영해서 신고하기 API 제작하겠습니다! 감사합니다~! |
SELECT cp.id, u.nickname, cp.title, cp.body, cp.content_url, cp.content_title, cp.content_description, cp.thumbnail_url, cp.created_at | ||
FROM community_post cp | ||
JOIN "user" u ON cp.user_id = u.id | ||
LEFT JOIN community_post_report_user cpru ON cp.id = cpru.community_post_id AND cpru.report_user_id = $1 |
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.
찾아보니 LEFT JOIN을 사용하는 것이 가장 일반적인 방법이라고 합니다!
다른 방법으로는 EXCEPT, NOT EXISTS, NOT IN 등이 있습니다.
LEFT JOIN의 성능이 안 좋으면 나중에 이런 방법들과 비교해서 개선해보려는데 어떠세요?-? @jokj624 @HYOSITIVE
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.
LEFT JOIN
후 NULL
조건으로 필터링하는 로직 확인했습니다! 성능 상 큰 문제는 없을 것 같아요. 당장은 신고된 글 자체 개수가 많지 않으니...!
const getCommunityPostsCount = async (client, userId) => { | ||
const { rows } = await client.query( | ||
` | ||
SELECT COUNT(*)::int |
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.
전체 커뮤니티 게시글 수를 조회하는 쿼리문도 LEFT JOIN을 사용해 신고글을 필터링했습니다!
@@ -85,6 +85,7 @@ router.get( | |||
router.get( | |||
'/posts', | |||
checkUser, | |||
[...communityValidator.getCommunityPostsValidator, validate], |
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.
validator 적용 확인했습니다!
@yubinquitous 2차 리뷰 완료했습니다! 정아 어프룹 후에 머지 부탁드려요~ |
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.
확인했습니다 고생하셨어요 !
작업 내용