From 64ffe805775311399d9b4c5415e9e3b7cc6518dc Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Mon, 19 Aug 2024 22:04:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20total=20count=20=EB=82=B4=EC=97=AD=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/statistics/job/HeroStatisticsJob.kt | 101 ++++++++++++------ 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/com/hero/alignlab/batch/statistics/job/HeroStatisticsJob.kt b/src/main/kotlin/com/hero/alignlab/batch/statistics/job/HeroStatisticsJob.kt index 6cf526d..dce06f5 100644 --- a/src/main/kotlin/com/hero/alignlab/batch/statistics/job/HeroStatisticsJob.kt +++ b/src/main/kotlin/com/hero/alignlab/batch/statistics/job/HeroStatisticsJob.kt @@ -35,36 +35,77 @@ class HeroStatisticsJob( ) { suspend fun sendHeroStatistics(title: String, fromDate: LocalDateTime, toDate: LocalDateTime) { coroutineScope { - val groupCount = async(Dispatchers.IO) { + /** 그룹 */ + val groupCountByCreatedAt = async(Dispatchers.IO) { groupRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val groupUserCount = async(Dispatchers.IO) { + } + val groupTotalCount = async(Dispatchers.IO) { + groupRepository.count() + } + val groupUserCountByCreatedAt = async(Dispatchers.IO) { groupUserRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val discussionCount = async(Dispatchers.IO) { + } + val groupUserTotalCount = async(Dispatchers.IO) { + groupUserRepository.count() + } + + /** 문의하기 */ + val discussionCountByCreatedAt = async(Dispatchers.IO) { discussionRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val syslogCount = async(Dispatchers.IO) { + } + val discussionTotalCount = async(Dispatchers.IO) { + discussionRepository.count() + } + + /** syslog */ + val syslogCountByCreatedAt = async(Dispatchers.IO) { systemActionLogRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val poseNotificationCount = async(Dispatchers.IO) { + } + val syslogTotalCount = async(Dispatchers.IO) { + systemActionLogRepository.count() + } + + /** 포즈 */ + val poseNotificationCountByCreatedAt = async(Dispatchers.IO) { poseNotificationRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val poseSnapshotCount = async(Dispatchers.IO) { + } + val poseNotificationTotalCount = async(Dispatchers.IO) { + poseNotificationRepository.count() + } + val poseSnapshotCountByCreatedAt = async(Dispatchers.IO) { poseSnapshotRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val credentialUserInfoCount = async(Dispatchers.IO) { + } + val poseSnapshotTotalCount = async(Dispatchers.IO) { + poseSnapshotRepository.count() + } + + /** 회원 */ + val credentialUserInfoCountByCreatedAt = async(Dispatchers.IO) { credentialUserInfoRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val oAuthUserInfoCount = async(Dispatchers.IO) { + } + val credentialUserInfoCountTotalCount = async(Dispatchers.IO) { + credentialUserInfoRepository.count() + } + val oAuthUserInfoCountByCreatedAt = async(Dispatchers.IO) { oAuthUserInfoRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val userInfoCount = async(Dispatchers.IO) { + } + val oAuthUserInfoTotalCount = async(Dispatchers.IO) { + oAuthUserInfoRepository.count() + } + val userInfoCountByCreatedAt = async(Dispatchers.IO) { userInfoRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() - val imageCount = async(Dispatchers.IO) { + } + val userInfoTotalCount = async(Dispatchers.IO) { + userInfoRepository.count() + } + + /** 이미지 */ + val imageCountByCreatedAt = async(Dispatchers.IO) { imageRepository.countByCreatedAtBetween(fromDate, toDate) - }.await() + } + val imageTotalCount = async(Dispatchers.IO) { + imageRepository.count() + } val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") @@ -72,26 +113,26 @@ class HeroStatisticsJob( $title [${fromDate.format(formatter)} ~ ${toDate.format(formatter)}] 그룹 - - 그룹 생성수 : $groupCount - - 그룹 유저 생성수 : $groupUserCount + - 그룹 생성수 : ${groupCountByCreatedAt.await()}건 [총합: ${groupTotalCount.await()}건] + - 그룹 유저 생성수 : ${groupUserCountByCreatedAt.await()}건 [총합: ${groupUserTotalCount.await()}건] 문의하기 - - 문의하기 생성수 : $discussionCount + - 문의하기 생성수 : ${discussionCountByCreatedAt.await()}건 [총합: ${discussionTotalCount.await()}건] API - - api 호출량 : $syslogCount + - api 호출량 : ${syslogCountByCreatedAt.await()}건 [총합: ${syslogTotalCount.await()}건] 포즈 - - 포즈 알림 설정수 : $poseNotificationCount - - 포즈 스냅샷 생성수 : $poseSnapshotCount + - 포즈 알림 설정수 : ${poseNotificationCountByCreatedAt.await()}건 [총합: ${poseNotificationTotalCount.await()}건] + - 포즈 스냅샷 생성수 : ${poseSnapshotCountByCreatedAt.await()}건 [총합: ${poseSnapshotTotalCount.await()}건] 회원 - - 일반 회원가입수 : $credentialUserInfoCount - - OAuth 회원가입수 : $oAuthUserInfoCount - - 유저 생성수 : $userInfoCount + - 일반 회원가입수 : ${credentialUserInfoCountByCreatedAt.await()}건 [총합: ${credentialUserInfoCountTotalCount.await()}건] + - OAuth 회원가입수 : ${oAuthUserInfoCountByCreatedAt.await()}건 [총합: ${oAuthUserInfoTotalCount.await()}건] + - 유저 생성수 : ${userInfoCountByCreatedAt.await()}건 [총합: ${userInfoTotalCount.await()}건] 이미지 - - 이미지 생성수 : $imageCount + - 이미지 생성수 : ${imageCountByCreatedAt.await()}건 [총합: ${imageTotalCount.await()}건] """.trimIndent() discordWebhookService.sendMessage(SendMessageRequest(message))