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
[BE] issue188: 스터디 상태 자동 변경 #191
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.
디우 기능 잘 구현해주셨네요
스케쥴링을 맡아본 적은 없지만 코드따라가면서 보니 이해가 쉬웠네요
@@ -28,7 +28,7 @@ CREATE TABLE study | |||
max_member_count INTEGER, | |||
created_at DATETIME not null, | |||
enrollment_end_date DATE, | |||
start_date DATE, | |||
start_date DATE not null, |
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.
not null 굿
@@ -27,7 +26,7 @@ private static Runnable runnable(final StudyService studyService) { | |||
@Transactional | |||
public void run() { | |||
LOGGER.debug(LocalDateTime.now() + " : " + "start moamoa scheduled task!"); | |||
studyService.autoCloseStudies(); | |||
studyService.autoUpdateStatus(); |
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.
아하 이렇게 한거군요!
46608ec
to
f10eb90
Compare
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorResponse(e.getMessage())); | ||
} | ||
|
||
@ExceptionHandler(RuntimeException.class) | ||
public ResponseEntity<ErrorResponse> handleInternalServerError(RuntimeException e) { | ||
e.printStackTrace(); | ||
log.error("RuntimeException : {}", e.getMessage()); |
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.
👍
@@ -95,19 +95,20 @@ public void participate(final Long memberId) { | |||
} | |||
} | |||
|
|||
private boolean isFullOfCapacity() { | |||
return recruitPlanner.hasCapacity() && recruitPlanner.getCapacity() == participants.getSize(); | |||
public void changeStatus(final LocalDate now) { |
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.
Study 객체에서 상태 관리 👍
this.enrollmentEndDate = getNullableDate(study.getEnrollmentEndDate()); | ||
this.startDate = study.getStartDate().toString(); | ||
this.endDate = getNullableDate(study.getEndDate()); | ||
this.maxMemberCount = study.getMaxMemberCount(); |
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.
명세 변경 null 리팩터링 👍
final StudyPlanner studyPlanner = (StudyPlanner) o; | ||
return Objects.equals(startDate, studyPlanner.startDate) && Objects.equals(endDate, studyPlanner.endDate); | ||
private boolean isNeedToChangeProgress(final LocalDate now) { | ||
return (studyStatus.equals(PREPARE)) && (startDate.isAfter(now) || startDate.isEqual(now)); |
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.
밑에 있는 isPreparing
메서드 써도 좋을 것 같아요!
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 StudyStatus getStudyStatus() { | ||
return studyStatus; | ||
private boolean isNeedToCloseStudy(final LocalDate now) { | ||
return (endDate != null) && (studyStatus.equals(IN_PROGRESS)) && (endDate.isAfter(now) || endDate.isEqual(now)); |
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.
여기도 isProgress 메서드 써도 좋을 것 같습니다
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 class RecruitPlanner { | ||
|
||
@Column(name = "max_member_count") | ||
private Integer max; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Enumerated(value = STRING) |
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.
value 제거해주세요
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.
넵!! 일관성 있게 나머지 @Enumerated 도 통일해주었습니다!
if (isNeedToCloseStudy(now)) { | ||
studyStatus = DONE; | ||
} | ||
if (isNeedToChangeProgress(now)) { | ||
studyStatus = IN_PROGRESS; | ||
} |
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 (isNeedToCloseStudy(now)) { | |
studyStatus = DONE; | |
} | |
if (isNeedToChangeProgress(now)) { | |
studyStatus = IN_PROGRESS; | |
} | |
if (isNeedToChangeStatus(now)) { | |
studyStatus = nextStatus(now); | |
} |
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 autoCloseStudyStatus() { | ||
given(dateTimeSystem.now()).willReturn(LocalDateTime.now()); | ||
|
||
sut.getRunnable().run(); | ||
|
||
final Study linuxStudy = studyRepository.findById(linuxStudyId).orElseThrow(); | ||
|
||
assertThat(linuxStudy.isCloseStudy()).isEqualTo(true); |
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.
isAfter 케이스 확인해주세요~
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.
수정하였습니다!
Study 불변식 확인하는 코드 부탁드려요. |
…oamoa into feat/188-study-auto-close # Conflicts: # backend/src/test/java/com/woowacourse/acceptance/study/GettingStudyDetailsAcceptanceTest.java
…oamoa into feat/188-study-auto-close
|
||
@Bean | ||
public ApplicationRunner runner() { | ||
return args -> { | ||
log.debug("hello !"); | ||
}; | ||
} |
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.
없애주세요
요약
스터디 상태 자동 변경
세부사항
IN_PROGRESS
상태가 된다.DONE
상태가 된다.IN_PROGRESS
를 유지한다.""
가 아닌 "null" 을 반환한다.close #188