From e2646ea827f5d4e05c4164635d96ece28041f356 Mon Sep 17 00:00:00 2001 From: Taehoon Kim Date: Sat, 7 Dec 2024 13:04:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BA=90=EC=8B=9C=20=EC=9B=9C=EC=97=85?= =?UTF-8?q?=20=EB=B2=94=EC=9C=84=20=ED=99=95=EC=9E=A5=20(#243)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 캐시 웜업시 미팅 참여 내역도 함께 캐싱 * fix: 매칭 결과 캐시 웜업 시 결제 조건 검증 로직 수정 --- .../admin/service/AdminService.kt | 42 +++++++++++++++---- .../meetingteam/dao/UserTeamDao.kt | 5 ++- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/uoslife/servermeeting/admin/service/AdminService.kt b/src/main/kotlin/uoslife/servermeeting/admin/service/AdminService.kt index 331a41b6..7712eb51 100644 --- a/src/main/kotlin/uoslife/servermeeting/admin/service/AdminService.kt +++ b/src/main/kotlin/uoslife/servermeeting/admin/service/AdminService.kt @@ -12,6 +12,7 @@ import uoslife.servermeeting.match.service.MatchingService import uoslife.servermeeting.meetingteam.dao.UserTeamDao import uoslife.servermeeting.payment.dto.response.PaymentResponseDto import uoslife.servermeeting.payment.service.PaymentService +import uoslife.servermeeting.user.repository.UserRepository import uoslife.servermeeting.user.service.UserService import uoslife.servermeeting.verification.util.VerificationConstants import uoslife.servermeeting.verification.util.VerificationUtils @@ -23,6 +24,7 @@ class AdminService( @Qualifier("PortOneService") private val paymentService: PaymentService, private val matchingService: MatchingService, private val userTeamDao: UserTeamDao, + private val userRepository: UserRepository, ) { companion object { private val logger = LoggerFactory.getLogger(AdminService::class.java) @@ -54,14 +56,40 @@ class AdminService( @Async fun warmUpCacheAsync(season: Int) { logger.info("[캐시 웜업 시작]") - val participants = userTeamDao.findAllParticipantsBySeasonAndType(season) - participants.forEach { participant -> - try { - matchingService.getMatchInfo(participant.userId, participant.teamType, season) - } catch (e: Exception) { - logger.info("[캐시 웜업 실패] userId: ${participant.userId} message: ${e.message}") + + try { + logger.info("[미팅 참여 정보 캐시 웜업 시작]") + val allUsers = userRepository.findAll() + allUsers.forEach { user -> + user.id?.let { userId -> + try { + matchingService.getUserMeetingParticipation(userId, season) + } catch (e: Exception) { + logger.info("[미팅 참여 정보 캐시 웜업 실패] userId: $userId message: ${e.message}") + } + } + } + logger.info("[미팅 참여 정보 캐시 웜업 완료] 대상 인원: ${allUsers.size}") + } catch (e: Exception) { + logger.error("[미팅 참여 정보 캐시 웜업 전체 실패] message: ${e.message}") + } + + try { + logger.info("[매칭 결과 캐시 웜업 시작]") + val participants = userTeamDao.findAllParticipantsBySeasonAndType(season) + participants.forEach { participant -> + try { + matchingService.getMatchInfo(participant.userId, participant.teamType, season) + } catch (e: Exception) { + logger.info( + "[매칭 결과 캐시 웜업 실패] userId: ${participant.userId} message: ${e.message}" + ) + } } + logger.info("[매칭 결과 캐시 웜업 완료] 대상 인원: ${participants.size}") + } catch (e: Exception) { + logger.error("[매칭 결과 캐시 웜업 전체 실패] message: ${e.message}") } - logger.info("[캐시 웜업 성공] 대상 인원: ${participants.size}") + logger.info("[캐시 웜업 완료]") } } diff --git a/src/main/kotlin/uoslife/servermeeting/meetingteam/dao/UserTeamDao.kt b/src/main/kotlin/uoslife/servermeeting/meetingteam/dao/UserTeamDao.kt index 4333e644..e09b0d7c 100644 --- a/src/main/kotlin/uoslife/servermeeting/meetingteam/dao/UserTeamDao.kt +++ b/src/main/kotlin/uoslife/servermeeting/meetingteam/dao/UserTeamDao.kt @@ -124,13 +124,14 @@ class UserTeamDao( ) .from(userTeam) .join(userTeam.team, meetingTeam) - .leftJoin(payment) + .join(payment) .on(payment.meetingTeam.eq(meetingTeam)) .where( meetingTeam.season.eq(season), + payment.meetingTeam.type.eq(userTeam.team.type), + payment.status.eq(PaymentStatus.SUCCESS) ) .groupBy(userTeam.user.id, userTeam.team.type) - .having(payment.status.eq(PaymentStatus.SUCCESS).count().eq(payment.count())) .fetch() } }