Skip to content

Commit

Permalink
refactor: 알림 조회 기준 시간을 파라미터로 받도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
coli-geonwoo committed Sep 26, 2024
1 parent 77af34d commit f887008
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.ody.notification.domain.Notification;
import com.ody.notification.domain.NotificationStatus;
import com.ody.notification.domain.NotificationType;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
Expand All @@ -15,10 +16,10 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
from Notification noti
left join fetch Mate m on noti.mate = m
left join Meeting meet on m.meeting = meet
where meet.id = :meetingId and noti.sendAt <= now()
where meet.id = :meetingId and noti.sendAt <= :time
order by noti.sendAt asc
""")
List<Notification> findAllMeetingLogs(Long meetingId);
List<Notification> findAllMeetingLogsBeforeThanEqual(Long meetingId, LocalDateTime time);

@Query("""
select noti
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void schedulePendingNotification() {

@DisabledDeletedFilter
public NotiLogFindResponses findAllMeetingLogs(Long meetingId) {
List<Notification> notifications = notificationRepository.findAllMeetingLogs(meetingId);
List<Notification> notifications = notificationRepository.findAllMeetingLogsBeforeThanEqual(meetingId, LocalDateTime.now());
return NotiLogFindResponses.from(notifications);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void findAllMeetingLogsById() {
notificationRepository.save(notification1);
notificationRepository.save(notification2);

List<Notification> notifications = notificationRepository.findAllMeetingLogs(odyMeeting.getId());
List<Notification> notifications = notificationRepository.findAllMeetingLogsBeforeThanEqual(odyMeeting.getId(), LocalDateTime.now());

assertThat(notifications.size()).isEqualTo(2);
}
Expand Down Expand Up @@ -86,7 +86,7 @@ void findAllNotificationsById() {
notificationRepository.save(pastNotification);
notificationRepository.save(futureNotification);

List<Notification> notifications = notificationRepository.findAllMeetingLogs(odyMeeting.getId());
List<Notification> notifications = notificationRepository.findAllMeetingLogsBeforeThanEqual(odyMeeting.getId(), LocalDateTime.now());

assertThat(notifications.size()).isOne();
}
Expand Down

0 comments on commit f887008

Please sign in to comment.