Skip to content

Commit

Permalink
test: 알람 테스트 - 음식 상영회
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 committed Feb 7, 2024
1 parent 32e4a7d commit 143868c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@ private void notifyReservation() {
}
}

@Scheduled(cron = "0 0/3 * * * *")
private void notifyTestReservation() {
LocalDateTime now = LocalDateTime.now().withSecond(0).withNano(0);
LocalDateTime reservationTime = now.plusDays(1);

System.out.println("test");

//userScreening에서 isBookMarked인 것들 중에서 user id, screening id가져와서 List<User> List<Screening>
//screening에서 startDate가져와서 startDate가 내일이면 알람을 보낼 수 있게 짜봐 fcm이랑 스프링 쓰고 있어

List<UserScreening> bookmarkedUserScreenings = userScreeningAdaptor.findByBookMarked();

for (UserScreening userScreening : bookmarkedUserScreenings) {
LocalDateTime screeningStartDate = userScreening.getScreening().getScreeningStartDate();

// 오늘이 screeningStartDate의 하루 전인 경우 해당 Screening을 가져옴
if (screeningStartDate.toLocalDate().isEqual(ChronoLocalDate.from(reservationTime))) {
Long userId = userScreening.getUser().getId();
if (checkFcmExists(userId)) {
NotificationRequest notificationRequests = new NotificationRequest(userScreening.getScreening(), userId, userScreening.getScreening().getTitle());
sendNotifications(notificationRequests);
}
}
}
}

// @Scheduled(cron = "0 0/1 * * * *")
// private void notifyTestReservation() {
// LocalDateTime now = LocalDateTime.now().withSecond(0).withNano(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public List<UserScreening> findByUserId(Long userId) {
.fetch();
}

//TODO screeningdate 지나면 x
public List<Screening> findBookmarkedUserScreening(Long userId) {
return queryFactory
.select(screening)
Expand Down

0 comments on commit 143868c

Please sign in to comment.