Skip to content

Commit

Permalink
[FEAT] 테스트 코드 제외하고, DB 스케줄링 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseul106 committed Jan 23, 2024
1 parent f8c9b78 commit c7549fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,4 @@ private boolean checkHasActionPlan(Seed seed) {
List<ActionPlan> actionPlansBySeedId = actionPlanRepository.findAllBySeedId(seed.getId());
return !actionPlansBySeedId.isEmpty();
}

@Scheduled(cron = "${schedules.cron.reward.publish}", zone = "Asia/Seoul")
public void updateLockStatusForExpiredSeeds() {
int updatedCount = seedRepository.updateLockStatusForExpiredSeeds();
System.out.println("Updated " + updatedCount + " seeds.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ public interface SeedService {

//* 씨앗 잠금 해제
void unlockSeed(Long seedId);

void updateLockStatusForExpiredSeeds();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.growthookserver.common.util;

import com.example.growthookserver.api.seed.repository.SeedRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@RequiredArgsConstructor
public class SchedulerUtil {

private final SeedRepository seedRepository;
@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul")
@Transactional
public void updateLockStatusForExpiredSeeds() {
int updatedCount = seedRepository.updateLockStatusForExpiredSeeds();
System.out.println("Updated " + updatedCount + " seeds.");
}
}

This file was deleted.

0 comments on commit c7549fd

Please sign in to comment.