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

[FEAT] 커뮤니티 게시글 전체조회 API #345

Merged
merged 24 commits into from
Apr 9, 2024
Merged

Conversation

yubinquitous
Copy link
Member

작업 내용

  • 커뮤니티 게시글 전체조회 API 구현
  • 구현 결과
    image

@yubinquitous yubinquitous self-assigned this Mar 25, 2024
@yubinquitous yubinquitous added 🚀 enhancement New feature or request 🤓 yubin labels Mar 25, 2024
functions/config/swagger.js Show resolved Hide resolved
functions/db/community.js Outdated Show resolved Hide resolved
Copy link
Member

@HYOSITIVE HYOSITIVE left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 댓글 하나 남겼는데 정아 의견도 들어보고 결정하면 될 것 같아요~!

functions/db/community.js Outdated Show resolved Hide resolved
Copy link
Member

@jokj624 jokj624 left a comment

Choose a reason for hiding this comment

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

댓글 남겼습니다!

functions/api/routes/community/communityPostsGET.js Outdated Show resolved Hide resolved
functions/config/swagger.js Show resolved Hide resolved
functions/db/community.js Outdated Show resolved Hide resolved
functions/db/community.js Outdated Show resolved Hide resolved
functions/api/routes/community/communityPostsGET.js Outdated Show resolved Hide resolved
functions/db/community.js Outdated Show resolved Hide resolved
functions/db/community.js Outdated Show resolved Hide resolved
@jokj624
Copy link
Member

jokj624 commented Mar 31, 2024

@yubinquitous community_post_report_user 테이블 추가됐으니 해당 로직 추가해주시면 될 것 같아요!

@HYOSITIVE
Copy link
Member

HYOSITIVE commented Apr 1, 2024

@yubinquitous community_post_report_user 테이블 추가됐으니 해당 로직 추가해주시면 될 것 같아요!

@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
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

LEFT JOINNULL 조건으로 필터링하는 로직 확인했습니다! 성능 상 큰 문제는 없을 것 같아요. 당장은 신고된 글 자체 개수가 많지 않으니...!

const getCommunityPostsCount = async (client, userId) => {
const { rows } = await client.query(
`
SELECT COUNT(*)::int
Copy link
Member Author

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],
Copy link
Member

Choose a reason for hiding this comment

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

validator 적용 확인했습니다!

@HYOSITIVE
Copy link
Member

@yubinquitous 2차 리뷰 완료했습니다! 정아 어프룹 후에 머지 부탁드려요~

Copy link
Member

@jokj624 jokj624 left a comment

Choose a reason for hiding this comment

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

확인했습니다 고생하셨어요 !

@jokj624 jokj624 merged commit f2a14eb into develop Apr 9, 2024
@jokj624 jokj624 deleted the feature/338 branch April 9, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request 🤓 yubin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 커뮤니티 글 전체 조회 API
3 participants