Skip to content

Commit 3b1d76f

Browse files
authored
Merge pull request #52 from oodd-team/OD-41
likeCount, commentCount 쿼리 수정
2 parents c4cbd42 + 255ea3d commit 3b1d76f

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/post/post.service.ts

+32-4
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,23 @@ export class PostService {
109109
'postImage.status = :status AND postImage.orderNum = :orderNum',
110110
{ status: 'activated', orderNum: 1 },
111111
)
112-
.leftJoinAndSelect('post.postLikes', 'postLike')
112+
.leftJoinAndSelect(
113+
'post.postLikes',
114+
'postLike',
115+
'postLike.status = :likeStatus',
116+
{
117+
likeStatus: 'activated',
118+
},
119+
)
113120
.leftJoinAndSelect('postLike.user', 'postLikeUser')
114-
.leftJoinAndSelect('post.postComments', 'postComment')
121+
.leftJoinAndSelect(
122+
'post.postComments',
123+
'postComment',
124+
'postComment.status = :commentStatus',
125+
{
126+
commentStatus: 'activated',
127+
},
128+
)
115129
.leftJoinAndSelect('postComment.user', 'postCommentUser')
116130
.where('post.status = :status', { status: 'activated' })
117131
.andWhere('post.user.id = :userId', { userId })
@@ -377,9 +391,23 @@ export class PostService {
377391
{ imageStatus: 'activated' },
378392
)
379393
.leftJoinAndSelect('post.user', 'user')
380-
.leftJoinAndSelect('post.postLikes', 'postLike')
394+
.leftJoinAndSelect(
395+
'post.postLikes',
396+
'postLike',
397+
'postLike.status = :likeStatus',
398+
{
399+
likeStatus: 'activated',
400+
},
401+
)
381402
.leftJoinAndSelect('postLike.user', 'postLikeUser')
382-
.leftJoinAndSelect('post.postComments', 'postComment')
403+
.leftJoinAndSelect(
404+
'post.postComments',
405+
'postComment',
406+
'postComment.status = :commentStatus',
407+
{
408+
commentStatus: 'activated',
409+
},
410+
)
383411
.leftJoinAndSelect('postComment.user', 'postCommentUser')
384412
.leftJoinAndSelect(
385413
'post.postClothings',

0 commit comments

Comments
 (0)