Skip to content

Commit

Permalink
Merge pull request #191 from Team-MindWay/190-all-scheduler-logging-add
Browse files Browse the repository at this point in the history
🔀 :: 모든 스케줄러 Logging 추가
  • Loading branch information
Umjiseung authored Jun 11, 2024
2 parents bffd50d + c3dd03b commit 969e70d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mindway.server.v2.domain.event.service.ChangeEventStatusService;
import com.mindway.server.v2.global.annotation.ServiceWithTransaction;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -17,25 +18,30 @@

@ServiceWithTransaction
@RequiredArgsConstructor
@Slf4j
public class ChangeEventStatusServiceImpl implements ChangeEventStatusService {

private final EventRepository eventRepository;

public void execute() {
log.info("===================이벤트 스케줄러 시작===================");
List<Event> pendingEvents = eventRepository.findByStatus(Status.PENDING);
List<Event> nowEvents = eventRepository.findByStatus(Status.NOW);

saveChangeNow(pendingEvents);
saveChangePast(nowEvents);
log.info("===================이벤트 스케줄러 끝===================");
}

private void saveChangePast(List<Event> nowEvents) {
for (Event event: nowEvents) {
if (Objects.equals(event.getStarted_at(), LocalDate.now())) {
event.changeStatus(Status.PAST);
eventRepository.save(event);
log.info("EventId: {}, status: NOW -> PAST", event.getId());
}
}
log.info("===================EventNowToPast End===================");
}

private void saveChangeNow(List<Event> pendingEvents) {
Expand All @@ -50,8 +56,10 @@ private void saveChangeNow(List<Event> pendingEvents) {
if (now.after(endDate)) {
event.changeStatus(Status.NOW);
eventRepository.save(event);
log.info("EventId: {}, status: PENDING -> NOW", event.getId());
}
}
log.info("===================EventPendingToNow End===================");
} catch (ParseException e) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
import com.mindway.server.v2.domain.goal.service.GoalsDeleteService;
import com.mindway.server.v2.global.annotation.ServiceWithTransaction;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@ServiceWithTransaction
@RequiredArgsConstructor
@Slf4j
public class GoalsDeleteServiceImpl implements GoalsDeleteService {

private final GoalRepository goalRepository;

public void execute() {
log.info("===================목표 초기화 스케줄러 시작===================");
goalRepository.deleteAll();
log.info("===================목표 초기화 스케줄러 끝===================");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
import com.mindway.server.v2.domain.rank.service.DeleteRankService;
import com.mindway.server.v2.global.annotation.ServiceWithTransaction;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@ServiceWithTransaction
@RequiredArgsConstructor
@Slf4j
public class DeleteRankServiceImpl implements DeleteRankService {

private final RankRepository rankRepository;

public void execute() {
log.info("===================랭킹 초기화 스케줄러 시작===================");
rankRepository.deleteAll();
log.info("===================랭킹 초기화 스케줄러 시작===================");
}
}

0 comments on commit 969e70d

Please sign in to comment.