Skip to content

Commit

Permalink
REFACTOR: 매일 지정시간(자정) 매칭되지 않은 코고를 삭제하는 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdjww committed Nov 15, 2024
1 parent 70ea175 commit 5eb20dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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;
import org.springframework.transaction.annotation.Transactional;

@Component
@Aspect
@Slf4j
public class ApplicationCleanupAspect {

private final ApplicationRepository applicationRepository;
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>

@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();

}

0 comments on commit 5eb20dc

Please sign in to comment.