Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ WHERE s.user_id IN (:userIds)
""", nativeQuery = true)
List<Object[]> findTopShorlogIdByUserIdsOrderByPopularity(@Param("userIds") List<Long> userIds);

// 쇼로그 또는 블로그 중 하나라도 작성한 유저 id
@Query(value = """
SELECT DISTINCT user_id
FROM (
SELECT s.user_id FROM shorlog s
UNION
SELECT b.user_id FROM blogs b
) t
""", nativeQuery = true)
List<Long> findDistinctUserIdsWithAnyPost();


@Query("""
select distinct s from Shorlog s
left join fetch s.user u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ public List<CreatorListResponseDto> getCreators(Long userId) {
public List<FullCreatorListResponseDto> getCreatorsFull(Long viewerIdOrNull) {

List<User> allUsers = userRepository.findAll();
Set<Long> creatorIds = new HashSet<>(shorlogRepository.findDistinctUserIdsWithAnyPost());
allUsers = allUsers.stream()
.filter(user -> creatorIds.contains(user.getId()))
.toList();

List<Long> allUserIds = allUsers.stream().map(User::getId).toList();

// 로그인 여부 분기
Expand Down
Loading