Skip to content

Commit

Permalink
Merge pull request #67 from minseok1015/dev
Browse files Browse the repository at this point in the history
feat : zum오타 변경
  • Loading branch information
minseok1015 authored Aug 10, 2024
2 parents c3173e3 + 9fa0063 commit 7799789
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public RankController(RankService rankService) {
@Autowired
private KeywordService keywordService;

@Autowired
private SchedulerService schedulerService;



// 최대 재시도 횟수와 재시도 간격 (초)
private static final int MAX_RETRIES = 5;
Expand Down Expand Up @@ -123,6 +127,11 @@ public void updateZum(){
keywordService.performDailyTasksZum();
}

@GetMapping("/update")
public void update(){
schedulerService.performHourlyTasks();
}

@GetMapping("/naver")
public List<Reference> getRankFromSignal() {
String url = "https://www.signal.bz/";
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/store/itpick/backend/service/SchedulerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ private <T> T executeWithRetries(Callable<T> action, String actionName) {


// 매 시간마다 실행하는 작업
@Scheduled(cron = "0 0,15,30,45 * * * *")
@Transactional
@Scheduled(cron = "0 0,15,20,30,45 * * * *")
public void performScheduledTasks() {
log.info("Starting scheduled tasks...");
if (isDailyTaskTime()) {
Expand All @@ -77,19 +78,20 @@ public void performScheduledTasks() {
private boolean isDailyTaskTime() {
LocalTime now = LocalTime.now();
// return now.getHour() == 11 && now.getMinute() == 15;
return now.getMinute() == 45;
return now.getMinute() == 5;
}

private boolean isMonday() {
return LocalDate.now().getDayOfWeek() == DayOfWeek.MONDAY;
}

// 시간별 크롤링 작업
private void performHourlyTasks() {
@Transactional
public void performHourlyTasks() {
try {
executeWithRetries(() -> seleniumService.useDriverForNaver("https://www.signal.bz/"), "Naver 데이터 수집");
executeWithRetries(() -> seleniumService.useDriverForMnate("https://m.nate.com/"), "Nate 데이터 수집");
executeWithRetries(() -> seleniumService.useDriverForMnate("https://news.zum.com/"), "Zum 데이터 수집");
executeWithRetries(() -> seleniumService.useDriverForZum("https://news.zum.com/"), "Zum 데이터 수집");

/** 일간 통합 랭킹 저장 **/
redis.saveTotalRanking(PeriodType.BY_REAL_TIME);
Expand All @@ -101,7 +103,8 @@ private void performHourlyTasks() {
}

// 18시에 실행하는 Daily 작업
private void performDailyTasks() {
@Transactional
public void performDailyTasks() {
log.info("Starting scheduled tasks...performing DailyTask");
performHourlyTasks(); // 매일 18시에 hourlyTask를 포함

Expand All @@ -121,7 +124,8 @@ private void performDailyTasks() {
}

// 매주 월요일 18시에 실행하는 Weekly 작업
private void performWeeklyTasks() {
@Transactional
public void performWeeklyTasks() {
log.info("Starting weekly task...");
/**
* Redis에서 주간 랭킹 계산, 생성
Expand Down

0 comments on commit 7799789

Please sign in to comment.