Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 모임 시작, 종료 알림이 모임 참여자가 3명 이상이 아니라면, 발행되지않도록 수정 #231

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@Transactional(readOnly = true)
public class MeetingAlertPublisher {

private static final String KR_TIME_ZONE = "Asia/Seoul";
private static final String EVERY_ONE_MINUTES = "0 * * * * *";
private static final String EVERY_12PM = "0 0 12 * * *";

Expand All @@ -24,18 +25,20 @@ public class MeetingAlertPublisher {

@Scheduled(cron = EVERY_ONE_MINUTES)
public void alertBeforeMeeting() {
var alertStart = LocalDateTime.now(ZoneId.of("Asia/Seoul")).plusMinutes(5).withNano(0).withSecond(0);
var alertStart = LocalDateTime.now(ZoneId.of(KR_TIME_ZONE)).plusMinutes(5).withNano(0).withSecond(0);
var alertEnd = alertStart.plusMinutes(1).withNano(0).withSecond(0);
var alertTargets = meetingRepository.findAlertMeetings(alertStart, alertEnd);
alertTargets.forEach(meeting -> eventPublisher.publishEvent(
new BeforeMeetingAlerted(meeting.getParticipantUserIds())
)
);
alertTargets.stream()
.filter(alertTarget -> alertTarget.getParticipantUserIds().size() > 2)
.forEach(meeting -> eventPublisher.publishEvent(
new BeforeMeetingAlerted(meeting.getParticipantUserIds())
)
);
}

@Scheduled(cron = EVERY_12PM)
public void alertEndMeeting() {
var today = LocalDateTime.now(ZoneId.of("Asia/Seoul"))
var today = LocalDateTime.now(ZoneId.of(KR_TIME_ZONE))
.withNano(0)
.withSecond(0)
.withMinute(0)
Expand All @@ -44,14 +47,16 @@ public void alertEndMeeting() {
var yesterday = today.minusDays(1);

var alertTargets = meetingRepository.findAlertMeetings(yesterday, today);
alertTargets.forEach(meeting -> eventPublisher.publishEvent(
new EndMeetingAlerted(meeting.getId(), meeting.getTitle(), meeting.getParticipantUserIds())
));
alertTargets.stream()
.filter(alertTarget -> alertTarget.getParticipantUserIds().size() > 2)
.forEach(meeting -> eventPublisher.publishEvent(
new EndMeetingAlerted(meeting.getId(), meeting.getTitle(), meeting.getParticipantUserIds())
));
}

@Scheduled(cron = EVERY_ONE_MINUTES)
public void alertEndMeetingForQa() {
var today = LocalDateTime.now(ZoneId.of("Asia/Seoul"))
var today = LocalDateTime.now(ZoneId.of(KR_TIME_ZONE))
.withNano(0)
.withSecond(0)
.withMinute(0)
Expand All @@ -61,8 +66,10 @@ public void alertEndMeetingForQa() {
var yesterday = today.minusDays(365);

var alertTargets = meetingRepository.findAlertMeetings(yesterday, future);
alertTargets.forEach(meeting -> eventPublisher.publishEvent(
new EndMeetingAlerted(meeting.getId(), meeting.getTitle(), meeting.getParticipantUserIds())
));
alertTargets.stream()
.filter(alertTarget -> alertTarget.getParticipantUserIds().size() > 2)
.forEach(meeting -> eventPublisher.publishEvent(
new EndMeetingAlerted(meeting.getId(), meeting.getTitle(), meeting.getParticipantUserIds())
));
}
}
Loading