Skip to content

Commit

Permalink
fix : 카테고리별 북마크 현황 조회 쿼리에 삭제되지 않은 북마크 조건 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
EunjiShin committed Nov 9, 2023
1 parent c6e0588 commit 17904bd
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -112,26 +112,27 @@ public List<Bookmark> findAllUnreadBookmark() {

@Override
public Map<Category, BookmarkReadStatus> findCategoryReadStatus(final Long memberId) {
Map<Category, BookmarkReadStatus> categoryBookmarkCounts = new HashMap<>();
Map<Category, BookmarkReadStatus> categoryBookmarkCounts = new LinkedHashMap<>();
List<Tuple> results = queryFactory
.select(
category,
category.id.count(),
bookmark.id.count(),
bookmark.readByUser.count()
)
.from(category)
.leftJoin(bookmark).on(category.id.eq(bookmark.category.id))
.where(
category.member.id.eq(memberId),
category.deletedAt.isNull()
category.deletedAt.isNull(),
bookmark.deletedAt.isNull()
)
.groupBy(category.id)
.orderBy(category.orderNum.asc())
.fetch();

for (Tuple result : results) {
Category currentCategory = result.get(category);
Long totalBookmarks = result.get(category.id.count());
Long totalBookmarks = result.get(bookmark.id.count());
Long readBookmarks = result.get(bookmark.readByUser.count());

BookmarkReadStatus status = new BookmarkReadStatus(totalBookmarks, readBookmarks);
Expand Down

0 comments on commit 17904bd

Please sign in to comment.