diff --git a/batch/src/main/kotlin/com/oksusu/susu/batch/summary/job/SusuStatisticsDailySummaryJob.kt b/batch/src/main/kotlin/com/oksusu/susu/batch/summary/job/SusuStatisticsDailySummaryJob.kt index 3b86fc4d..f3c823e2 100644 --- a/batch/src/main/kotlin/com/oksusu/susu/batch/summary/job/SusuStatisticsDailySummaryJob.kt +++ b/batch/src/main/kotlin/com/oksusu/susu/batch/summary/job/SusuStatisticsDailySummaryJob.kt @@ -37,58 +37,58 @@ class SusuStatisticsDailySummaryJob( parZipWithMDC( { withContext(Dispatchers.IO) { systemActionLogRepository.countByCreatedAtBetween(beforeOneDay, now) } }, { withContext(Dispatchers.IO) { userRepository.countByCreatedAtBetween(beforeOneDay, now) } }, - { withContext(Dispatchers.IO) { envelopeRepository.count() } }, { withContext(Dispatchers.IO) { envelopeRepository.countByCreatedAtBetween(beforeOneDay, now) } }, { withContext(Dispatchers.IO) { ledgerRepository.countByCreatedAtBetween(beforeOneDay, now) } }, { withContext(Dispatchers.IO) { friendRepository.countByCreatedAtBetween(beforeOneDay, now) } }, { withContext(Dispatchers.IO) { userWithdrawRepository.countByCreatedAtBetween(beforeOneDay, now) } }, - { withContext(Dispatchers.IO) { reportHistoryRepository.countByCreatedAtBetween(beforeOneDay, now) } } + { withContext(Dispatchers.IO) { reportHistoryRepository.countByCreatedAtBetween(beforeOneDay, now) } }, + { withContext(Dispatchers.IO) { userRepository.countActiveUsers() } } ) { systemActionLogCount, userCount, - totalEnvelopeCount, dailyEnvelopeCount, dailyLedgerCount, friendCount, userWithdrawCount, dailyReportHistoryCount, + totalActiveUserCount, -> DailySummaryMessage( now = now, - systemActionLogCount = systemActionLogCount, - userCount = userCount, - totalEnvelopeCount = totalEnvelopeCount, + dailySystemActionLogCount = systemActionLogCount, + dailyUserCount = userCount, dailyEnvelopeCount = dailyEnvelopeCount, dailyLedgerCount = dailyLedgerCount, - friendCount = friendCount, - userWithdrawCount = userWithdrawCount, - dailyReportHistoryCount = dailyReportHistoryCount + dailyFriendCount = friendCount, + dailyUserWithdrawCount = userWithdrawCount, + dailyReportHistoryCount = dailyReportHistoryCount, + totalActiveUserCount = totalActiveUserCount, ) }.run { discordClient.sendSummary(this.message()) } } private data class DailySummaryMessage( val now: LocalDateTime, - val systemActionLogCount: Long, - val userCount: Long, - val totalEnvelopeCount: Long, + val dailySystemActionLogCount: Long, + val dailyUserCount: Long, val dailyEnvelopeCount: Long, val dailyLedgerCount: Long, - val friendCount: Long, - val userWithdrawCount: Long, + val dailyFriendCount: Long, + val dailyUserWithdrawCount: Long, val dailyReportHistoryCount: Long, + val totalActiveUserCount: Long, ) { fun message(): DiscordMessageModel { return DiscordMessageModel( """ **[ 일단위 통계 알림 ${now.format("yyyyMMdd HH:mm:ss")} ]** - - 전날 종합 api 호출수 : $systemActionLogCount - - 전날 종합 유저 가입수 : $userCount - - 전날 종합 봉투 생성수 : $dailyEnvelopeCount - - 전체 봉투 생성수 : $totalEnvelopeCount - - 전날 종합 장부 생성수 : $dailyLedgerCount - - 전날 종합 친구 생성수 : $friendCount - - 전날 종합 유저 탈퇴수 : $userWithdrawCount + - 전날 종합 api 호출수 : $dailySystemActionLogCount + - 총합 실제 유저수 : $totalActiveUserCount + - 전날 신규 가입 유저수 : $dailyUserCount + - 전날 유저 탈퇴수 : $dailyUserWithdrawCount + - 전날 신규 봉투 생성수 : $dailyEnvelopeCount + - 전날 신규 장부 생성수 : $dailyLedgerCount + - 전날 신규 친구 생성수 : $dailyFriendCount - 전날 종합 신고수 : $dailyReportHistoryCount """.trimIndent() ) diff --git a/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/EnvelopeQRepository.kt b/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/EnvelopeQRepository.kt index cd5b1f80..aa85b48f 100644 --- a/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/EnvelopeQRepository.kt +++ b/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/EnvelopeQRepository.kt @@ -171,11 +171,13 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E ).from(qEnvelope) .join(qFriend).on(qEnvelope.friendId.eq(qFriend.id)) .join(qFriendRelationship).on(qEnvelope.friendId.eq(qFriendRelationship.friendId)) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( qEnvelope.id.eq(id), qEnvelope.uid.eq(uid), - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ).fetchFirst() } @@ -232,10 +234,12 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E qEnvelope.id.count() ) ).from(qEnvelope) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( qEnvelope.ledgerId.isNull, - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ).groupBy(qCategoryAssignment.categoryId) .fetch() } @@ -248,9 +252,11 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E qEnvelope.id.count() ) ).from(qEnvelope) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE), qEnvelope.ledgerId.isNull, qEnvelope.uid.notIn(uid) ).groupBy(qCategoryAssignment.categoryId) @@ -268,9 +274,11 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E qEnvelope.id.count() ) ).from(qEnvelope) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE), qEnvelope.ledgerId.isNull, qEnvelope.uid.notIn(uid), qEnvelope.createdAt.after(targetDate) @@ -286,11 +294,13 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E qEnvelope.id.count() ) ).from(qEnvelope) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( qEnvelope.uid.eq(uid), qEnvelope.ledgerId.isNull, - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ).groupBy(qCategoryAssignment.categoryId) .fetch() } @@ -312,7 +322,10 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E ).from(qEnvelope) .join(qUser).on(qEnvelope.uid.eq(qUser.id)) .join(qFriendRelationship).on(qEnvelope.friendId.eq(qFriendRelationship.friendId)) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .where( qEnvelope.amount.between(minAmount, maxAmount), qEnvelope.uid.notIn(uid) @@ -343,8 +356,8 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E .join(qUser).on(qEnvelope.uid.eq(qUser.id)) .join(qFriendRelationship).on(qEnvelope.friendId.eq(qFriendRelationship.friendId)) .join(qCategoryAssignment).on( - qEnvelope.id.eq(qCategoryAssignment.targetId) - .and(qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE)) + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ) .where( qEnvelope.amount.between(minAmount, maxAmount), @@ -366,8 +379,8 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E .join(qFriend).on(qEnvelope.friendId.eq(qFriend.id)) .join(qFriendRelationship).on(qEnvelope.friendId.eq(qFriendRelationship.friendId)) .join(qCategoryAssignment).on( - qEnvelope.id.eq(qCategoryAssignment.targetId) - .and(qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE)) + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ) /** where */ @@ -441,12 +454,14 @@ class EnvelopeQRepositoryImpl : EnvelopeQRepository, QuerydslRepositorySupport(E ).from(qEnvelope) .join(qFriend).on(qEnvelope.friendId.eq(qFriend.id)) .join(qFriendRelationship).on(qEnvelope.friendId.eq(qFriendRelationship.friendId)) - .join(qCategoryAssignment).on(qEnvelope.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qEnvelope.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) + ) .leftJoin(qLedger).on(qEnvelope.ledgerId.eq(qLedger.id)) .where( qEnvelope.uid.eq(uid), qEnvelope.type.eq(envelopeType), - qCategoryAssignment.targetType.eq(CategoryAssignmentType.ENVELOPE) ) return querydsl.executeSlice(query, pageable) diff --git a/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/LedgerQRepository.kt b/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/LedgerQRepository.kt index 1edfc3e2..6db7d95a 100644 --- a/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/LedgerQRepository.kt +++ b/domain/src/main/kotlin/com/oksusu/susu/domain/envelope/infrastructure/LedgerQRepository.kt @@ -48,12 +48,14 @@ class LedgerQRepositoryImpl : LedgerQRepository, QuerydslRepositorySupport(Ledge val query = JPAQuery(entityManager) .select(QSearchLedgerModel(qLedger, qCategoryAssignment)) .from(qLedger) - .join(qCategoryAssignment).on(qLedger.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qLedger.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) + ) .where( qLedger.uid.eq(spec.uid), qLedger.title.isContains(spec.title), qCategoryAssignment.categoryId.isIn(spec.categoryIds), - qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER), qLedger.startAt.isGoe(spec.fromStartAt), qLedger.startAt.isLoe(spec.toStartAt) ) @@ -65,11 +67,13 @@ class LedgerQRepositoryImpl : LedgerQRepository, QuerydslRepositorySupport(Ledge return JPAQuery(entityManager) .select(QLedgerDetailModel(qLedger, qCategoryAssignment)) .from(qLedger) - .join(qCategoryAssignment).on(qLedger.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qLedger.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) + ) .where( qLedger.id.eq(id), - qLedger.uid.eq(uid), - qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) + qLedger.uid.eq(uid) ).fetchOne() } @@ -82,8 +86,10 @@ class LedgerQRepositoryImpl : LedgerQRepository, QuerydslRepositorySupport(Ledge ) ) .from(qLedger) - .join(qCategoryAssignment).on(qLedger.id.eq(qCategoryAssignment.targetId)) - .where(qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER)) + .join(qCategoryAssignment).on( + qLedger.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) + ) .groupBy(qCategoryAssignment.categoryId) .fetch() } @@ -118,9 +124,11 @@ class LedgerQRepositoryImpl : LedgerQRepository, QuerydslRepositorySupport(Ledge ) ) .from(qLedger) - .join(qCategoryAssignment).on(qLedger.id.eq(qCategoryAssignment.targetId)) + .join(qCategoryAssignment).on( + qLedger.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) + ) .where( - qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER), qLedger.uid.notIn(uid), qLedger.createdAt.after(targetDate) ) @@ -138,8 +146,8 @@ class LedgerQRepositoryImpl : LedgerQRepository, QuerydslRepositorySupport(Ledge ) .from(qLedger) .join(qCategoryAssignment).on( - qLedger.id.eq(qCategoryAssignment.targetId) - .and(qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER)) + qLedger.id.eq(qCategoryAssignment.targetId), + qCategoryAssignment.targetType.eq(CategoryAssignmentType.LEDGER) ) .where(qLedger.uid.eq(uid)) .groupBy(qCategoryAssignment.categoryId) diff --git a/domain/src/main/kotlin/com/oksusu/susu/domain/user/infrastructure/UserQRepository.kt b/domain/src/main/kotlin/com/oksusu/susu/domain/user/infrastructure/UserQRepository.kt index 7a3759ed..f4135c29 100644 --- a/domain/src/main/kotlin/com/oksusu/susu/domain/user/infrastructure/UserQRepository.kt +++ b/domain/src/main/kotlin/com/oksusu/susu/domain/user/infrastructure/UserQRepository.kt @@ -16,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional @Transactional(readOnly = true) interface UserQRepository { fun getUserAndUserStatus(uid: Long): UserAndUserStatusModel? + + fun countActiveUsers(): Long } class UserQRepositoryImpl : UserQRepository, QuerydslRepositorySupport(User::class.java) { @@ -36,4 +38,15 @@ class UserQRepositoryImpl : UserQRepository, QuerydslRepositorySupport(User::cla .where(qUser.id.isEquals(uid)) .fetchFirst() } + + override fun countActiveUsers(): Long { + return JPAQuery(entityManager) + .select(qUser.count()) + .from(qUser) + .where( + qUser.oauthInfo.oAuthId.contains("withdraw").not(), + qUser.id.goe(200000) + ) + .fetchOne() ?: 0L + } } diff --git a/gradle.properties b/gradle.properties index 68801461..1575a309 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version=1.1.14 +version=1.1.15 kotlin.code.style=official