Skip to content

Commit

Permalink
fix: 유저 삭제시 NPE 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho committed Dec 1, 2023
1 parent 2b92616 commit 1836b3b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import com.spaceclub.user.domain.User;
import com.spaceclub.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Component
@RequiredArgsConstructor
public class AccountDeleteScheduler {
Expand All @@ -26,11 +28,12 @@ public class AccountDeleteScheduler {
// @Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul")
@Scheduled(fixedRate = 1000 * 60) // 테스트
public void deleteInactiveUsers() {
log.warn("deleteInactiveUsers() is called");
// LocalDateTime threeDaysAgoFromNow = LocalDateTime.now().minusDays(GRACE_DAYS_OF_DELETION);
LocalDateTime threeDaysAgoFromNow = LocalDateTime.now().minusMinutes(GRACE_DAYS_OF_DELETION);
List<User> usersToDelete = userRepository.findAllUserToDelete(threeDaysAgoFromNow).stream()
.map(User::changeStatusToDeleted)
.peek(kakaoOauthInfoSender::unlink)
.map(User::changeStatusToDeleted)
.toList();

userRepository.saveAll(usersToDelete);
Expand Down

0 comments on commit 1836b3b

Please sign in to comment.