-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: 미션 상태 업데이트 배치 스케줄러 구현 #81
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다ㅏ👍
저도 최대한 다음 주 내로 푸시 구현해볼게요...!!
@@ -30,6 +30,7 @@ dependencies { | |||
implementation 'org.springframework.boot:spring-boot-starter-validation' | |||
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.1.3' | |||
implementation 'org.springframework.boot:spring-boot-starter-data-redis' | |||
implementation("org.springframework.boot:spring-boot-starter-quartz") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
@Transactional | ||
public void batchUpdate(final Long missionId) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 메서드는 아직 구현 전인가용??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 이거 지워놓을게 !
if (now.isBefore(missionStart)) { | ||
return PENDING; | ||
} else if (now.isAfter(missionEnd)) { | ||
return CREATED; | ||
} | ||
|
||
if (mission.isMissionPeriod() && currentMemberCount <= 1) { | ||
return CANCELED; | ||
} | ||
|
||
if (mission.isMissionPeriod() && currentMemberCount > 1) { | ||
return IN_PROGRESS; | ||
} | ||
|
||
if (now.isAfter(missionEnd) && !missionMember.getCheckCompleted()) { | ||
return PENDING_COMPLETION; | ||
} | ||
|
||
if (now.isAfter(missionEnd) && missionMember.getCheckCompleted()) { | ||
return COMPLETED; | ||
} else { | ||
return ONGOING; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
public void batchUpdateStatus() { | ||
List<Mission> missions = missionRepository.findAll(); | ||
missions.forEach(mission -> { | ||
List<MissionMember> missionMembers = missionMemberRepository.findAllByMissionId(mission.getId()); | ||
int memberCount = missionMembers.size(); | ||
missionMembers | ||
.forEach(missionMember -> { | ||
missionMember.updateMissionStatus(mission, memberCount); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
return new MissionsResponse( | ||
new ProfileResponse(member.getNickname(), member.getCharacterType()), | ||
missionVerifications.stream() | ||
missionMembers.stream() | ||
.map(missionVerification -> new MissionResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 iterator 부분 missionMember
로 해도 좋을 것 같아요
(이전에 missionVerifications
여서 missionVerification
으로 남아 있는 것 같아요 :)
@Override | ||
protected ScheduleBuilder<CronTrigger> getScheduleBuilder() { | ||
// 00:00, 06:00, 12:00, 18:00 마다 실행 | ||
return CronScheduleBuilder.cronSchedule("0 0 */6 * * ?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
add mission_status varchar(50) null; | ||
|
||
alter table mission_member | ||
add check_completed boolean default false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
job-store-type: jdbc | ||
jdbc: | ||
initialize-schema: never | ||
schema: nexters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev
에서만 nexters
인 이유가 있나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우리 dev local DB 스키마가 nexters 라 동일 스키마 썼어요!
6b013c2
to
4501e74
Compare
Issue Number
close: #80
작업 개요
6시간 주기로 미션 상태 변경하는 배치 스케줄러 구현했습니다 ! (00:00, 06:00, 12:00, 18:00)
멀티 모듈로 변경하고 배치 애플리케이션을 따로 구성할까 생각해봤는데 현재 스펙에서는 오버엔지니어링인 것 같아
클러스터링을 제공하는 스프링 쿼츠 사용해서 스케줄러 돌리려고 합니다.
작업 사항
여기에 작성하세요
고민한 점들(필수 X)
여기에 작성하세요
스크린샷(필수 X)
여기에 작성하세요