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 @@ -45,8 +45,8 @@ ResponseEntity<GlobalResponse<AdminJoinWithdrawResDto>> getJoinWithdraw(
@Operation(summary = "잔존율 조회", description = """
7/30일 잔존율을 조회합니다.

- 7일 잔존율 : 전체 가입 유저 중 가입 후 7일째 되는 날 접속한 유저 비율
- 30일 잔존율 : 전체 가입 유저 중 가입 후 30일째 되는 날 접속한 유저 비율
- 7일 잔존율 : 전체 가입 유저 중 가입 후 7일 이내 접속한 유저 비율
- 30일 잔존율 : 전체 가입 유저 중 가입 후 30일 이내 접속한 유저 비율
""")
@SecurityRequirement(name = "bearerAuth")
@GetMapping("/users/retention")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.example.egobook_be.domain.user.repository.WithdrawReasonRepository;
import com.example.egobook_be.global.exception.CustomException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -28,7 +29,7 @@
import java.util.Map;
import java.util.stream.Collectors;


@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Expand Down Expand Up @@ -106,8 +107,10 @@ public AdminRetentionResDto getRetention() {
Long total7 = userRepository.countByCreatedAtBefore(today.minusDays(7).atStartOfDay());
Long total30 = userRepository.countByCreatedAtBefore(today.minusDays(30).atStartOfDay());

Long active7 = userActivityLogRepository.countRetainedUserOnDay(7);
Long active30 = userActivityLogRepository.countRetainedUserOnDay(30);
Long active7 = userActivityLogRepository.countRetainedUserWithinDays(7);
Long active30 = userActivityLogRepository.countRetainedUserWithinDays(30);

log.info("total7={}, total30={}, active7={}, active30={}", total7, total30, active7, active30);

return AdminStatMapper.getRetentionResDto(total7, total30, active7, active30);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public interface UserActivityLogRepository extends JpaRepository<UserActivityLog
SELECT COUNT(DISTINCT a.user_id)
FROM user_activity_log a
JOIN user u ON u.id = a.user_id
WHERE a.active_date = DATE(DATE_ADD(u.created_at, INTERVAL :days DAY))
WHERE a.active_date BETWEEN DATE(u.created_at)
AND DATE(DATE_ADD(u.created_at, INTERVAL :days DAY))
""", nativeQuery = true)
Long countRetainedUserOnDay(@Param("days") int days);
Long countRetainedUserWithinDays(@Param("days") int days);

@Query(value = """
SELECT active_date AS date, COUNT(DISTINCT user_id) AS count
Expand Down
Loading