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

feat: 미션 상태 업데이트 배치 스케줄러 구현 #81

Merged
merged 2 commits into from
Oct 27, 2024

Conversation

songyi00
Copy link
Member

Issue Number

close: #80

작업 개요

6시간 주기로 미션 상태 변경하는 배치 스케줄러 구현했습니다 ! (00:00, 06:00, 12:00, 18:00)
멀티 모듈로 변경하고 배치 애플리케이션을 따로 구성할까 생각해봤는데 현재 스펙에서는 오버엔지니어링인 것 같아
클러스터링을 제공하는 스프링 쿼츠 사용해서 스케줄러 돌리려고 합니다.

작업 사항

여기에 작성하세요

고민한 점들(필수 X)

여기에 작성하세요

스크린샷(필수 X)

여기에 작성하세요

@songyi00 songyi00 requested a review from kimyu0218 as a code owner October 26, 2024 13:19
@songyi00 songyi00 changed the title feat: 미션 상태 업데이트 배치 구현 feat: 미션 상태 업데이트 배치 스케줄러 구현 Oct 26, 2024
Copy link
Collaborator

@kimyu0218 kimyu0218 left a 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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

Comment on lines 88 to 91
@Transactional
public void batchUpdate(final Long missionId) {

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 메서드는 아직 구현 전인가용??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 이거 지워놓을게 !

Comment on lines 41 to 59
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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

Comment on lines +101 to +111
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);
});
});
}
Copy link
Collaborator

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(
Copy link
Collaborator

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 * * ?")
Copy link
Collaborator

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;
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev에서만 nexters인 이유가 있나요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우리 dev local DB 스키마가 nexters 라 동일 스키마 썼어요!

@songyi00 songyi00 merged commit 00041d7 into develop Oct 27, 2024
1 check passed
@songyi00 songyi00 deleted the feat/#80-scheduler branch October 27, 2024 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

미션 상태 관리
2 participants