Skip to content

Commit

Permalink
fix: popcorn Schedule 시간대 변경 월 -> 일
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 committed Feb 10, 2024
1 parent cff8ca7 commit 4ce77e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -28,6 +29,8 @@ public class PopcornAdaptor {
private static LocalDate today = LocalDate.now();
private static LocalDate startOfLastWeek = today.minusDays(today.getDayOfWeek().getValue() + 6); // 지난 주의 월요일
private static LocalDate endOfLastWeek = startOfLastWeek.plusDays(6); // 지난 주의 일요일
private static LocalDate startOfThisWeek = today.with(DayOfWeek.MONDAY);
private static LocalDate endOfThisWeek = today.with(DayOfWeek.SATURDAY);

@Transactional
public void save(Popcorn popcorn){
Expand All @@ -53,7 +56,7 @@ public List<RecommendedPopcorn> findTopThree() {

return jpaQueryFactory
.selectFrom(recommendedPopcorn)
.where(recommendedPopcorn.createdAt.between(startOfLastWeek.atStartOfDay(), endOfLastWeek.atTime(23, 59, 59)))
.where(recommendedPopcorn.createdAt.between(startOfThisWeek.atStartOfDay(), endOfThisWeek.atTime(23, 59, 59)))
.orderBy(
recommendedPopcorn.recommendationCount.desc(),
recommendedPopcorn.createdAt.desc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PopcornSchedule {
private final PopcornService popcornService;

// 매 주 일요일 0시 0분에 실행되도록 cron 설정-ㄱㄷ미
@Scheduled(cron = "0 0 0 * * MON")
@Scheduled(cron = "0 0 0 * * SUN")
public void scheduledMethod() {
popcornService.getTopRecommended();
System.out.println("매 주 일요일에 실행되는 작업");
Expand Down

0 comments on commit 4ce77e3

Please sign in to comment.