Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 유저 삭제시 npe 해결 #286

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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