From 5eb20dc390f0556935e8701971d36da58d4b39a8 Mon Sep 17 00:00:00 2001 From: oxdjww Date: Fri, 15 Nov 2024 22:17:29 +0900 Subject: [PATCH] =?UTF-8?q?REFACTOR:=20=EB=A7=A4=EC=9D=BC=20=EC=A7=80?= =?UTF-8?q?=EC=A0=95=EC=8B=9C=EA=B0=84(=EC=9E=90=EC=A0=95)=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=BD=94?= =?UTF-8?q?=EA=B3=A0=EB=A5=BC=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoffeeChat/aspect/ApplicationCleanupAspect.java | 3 +++ .../CoffeeChat/repository/ApplicationRepository.java | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/soongsil/CoffeeChat/aspect/ApplicationCleanupAspect.java b/src/main/java/com/soongsil/CoffeeChat/aspect/ApplicationCleanupAspect.java index 8b62392..e2a7c10 100644 --- a/src/main/java/com/soongsil/CoffeeChat/aspect/ApplicationCleanupAspect.java +++ b/src/main/java/com/soongsil/CoffeeChat/aspect/ApplicationCleanupAspect.java @@ -1,6 +1,7 @@ package com.soongsil.CoffeeChat.aspect; import com.soongsil.CoffeeChat.repository.ApplicationRepository; +import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.annotation.Aspect; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -8,6 +9,7 @@ @Component @Aspect +@Slf4j public class ApplicationCleanupAspect { private final ApplicationRepository applicationRepository; @@ -19,6 +21,7 @@ public ApplicationCleanupAspect(ApplicationRepository applicationRepository) { @Scheduled(cron = "0 0 0 * * ?") @Transactional public void deleteExpiredApplications() { + log.info("[*] Deleting expired applications.. "); // 매일 자정에 현재 시간보다 이전인 COGO 삭제 applicationRepository.deleteExpiredApplications(); } diff --git a/src/main/java/com/soongsil/CoffeeChat/repository/ApplicationRepository.java b/src/main/java/com/soongsil/CoffeeChat/repository/ApplicationRepository.java index 6b6837d..7202e45 100644 --- a/src/main/java/com/soongsil/CoffeeChat/repository/ApplicationRepository.java +++ b/src/main/java/com/soongsil/CoffeeChat/repository/ApplicationRepository.java @@ -21,7 +21,10 @@ public interface ApplicationRepository extends JpaRepository @Modifying @Transactional - @Query("DELETE FROM Application a WHERE a.possibleDate.date < CURRENT_DATE " + - "OR (a.possibleDate.date = CURRENT_DATE AND a.possibleDate.startTime < CURRENT_TIME)") + @Query("DELETE FROM Application a " + + "WHERE a.accept = 'UNMATCHED' " + + "AND (a.possibleDate.date < CURRENT_DATE " + + "OR (a.possibleDate.date = CURRENT_DATE AND a.possibleDate.startTime < CURRENT_TIME))") void deleteExpiredApplications(); + }