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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
43d759f
feat: 스케쥴러를 이용한 스터디 상태 자동 변경
tco0427 13935dd
refactor: 스케줄러 로직 개선
tco0427 edbdd6d
fix: 테스트 코드 수정
tco0427 1d37bc2
refactor: 응답 값이 없는 경우 null 반환
tco0427 b39181a
chore: 충돌 해결
tco0427 3bdaddf
Merge branch 'develop' of https://github.com/woowacourse-teams/2022-m…
tco0427 e224dd1
refactor: 메소드명 개선 및 Getter 추가
tco0427 604e9b4
refactor: 불필요한 메소드 제거
tco0427 f10eb90
refactor: log 개선
tco0427 a196411
refactor: 기존 메소드 활용
tco0427 5568c77
refactor: `@Enumerated` 통일
tco0427 7392e40
feat: 테스트 코드 수정
tco0427 ae0c1b0
refactor: StudyPlanner 수정
tco0427 d551ac7
Merge branch 'develop' of https://github.com/woowacourse-teams/2022-m…
tco0427 e2ebea9
Merge branch 'develop' of https://github.com/woowacourse-teams/2022-m…
tco0427 e1f1ce0
Merge branch 'develop' of https://github.com/woowacourse-teams/2022-m…
tco0427 dc4d4ea
feat: Study 불변식 검증 추가
tco0427 e87dc38
Merge branch 'develop' of https://github.com/woowacourse-teams/2022-m…
tco0427 3cc64c2
refactor: Auto에 Transactional 제거
tco0427 88aa874
fix: 불필요한 Bean 제거
tco0427 a89b0ba
test: 테스트 코드 개선
tco0427 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
backend/src/main/java/com/woowacourse/moamoa/MoamoaApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,10 @@ private Study(final Long id, final Content content, final Participants participa | |
throw new InvalidPeriodException(); | ||
} | ||
|
||
if (studyPlanner.isInappropriateCondition(createdAt.toLocalDate())) { | ||
throw new InvalidPeriodException(); | ||
} | ||
|
||
this.id = id; | ||
this.content = content; | ||
this.participants = participants; | ||
|
@@ -95,19 +99,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 commentThe reason will be displayed to describe this comment to others. Learn more. Study 객체에서 상태 관리 👍 |
||
recruitPlanner.updateRecruiting(now); | ||
studyPlanner.updateStatus(now); | ||
} | ||
|
||
public boolean isNeedToCloseRecruiting(LocalDate now) { | ||
return recruitPlanner.isNeedToCloseRecruiting(now); | ||
public boolean isProgressStatus() { | ||
return studyPlanner.isProgress(); | ||
} | ||
|
||
public void closeEnrollment() { | ||
recruitPlanner.closeRecruiting(); | ||
public boolean isCloseStudy() { | ||
return studyPlanner.isCloseStudy(); | ||
} | ||
|
||
public boolean isCloseEnrollment() { | ||
return recruitPlanner.isCloseEnrollment(); | ||
private boolean isFullOfCapacity() { | ||
return recruitPlanner.hasCapacity() && recruitPlanner.getCapacity() == participants.getSize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
backend/src/main/java/com/woowacourse/moamoa/study/domain/StudyStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package com.woowacourse.moamoa.study.domain; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum StudyStatus { | ||
|
||
PREPARE, IN_PROGRESS, DONE; | ||
|
||
public static StudyStatus find(String status) { | ||
return Arrays.stream(StudyStatus.values()) | ||
.filter(studyStatus -> studyStatus.name().equals(status)) | ||
.findAny() | ||
.get(); | ||
public StudyStatus nextStatus() { | ||
if (this.equals(PREPARE)) { | ||
return IN_PROGRESS; | ||
} | ||
if (this.equals(IN_PROGRESS)) { | ||
return DONE; | ||
} | ||
return PREPARE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 4 additions & 13 deletions
17
backend/src/main/java/com/woowacourse/moamoa/study/schedule/AutoCloseEnrollmentTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
package com.woowacourse.moamoa.study.schedule; | ||
|
||
import com.woowacourse.moamoa.MoamoaApplication; | ||
import com.woowacourse.moamoa.study.service.StudyService; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.scheduling.config.TriggerTask; | ||
import org.springframework.scheduling.support.CronTrigger; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@Slf4j | ||
public class AutoCloseEnrollmentTask extends TriggerTask { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(MoamoaApplication.class); | ||
|
||
public AutoCloseEnrollmentTask(final StudyService studyService) { | ||
super(runnable(studyService), new CronTrigger("@daily", ZoneId.of("Asia/Seoul"))); | ||
} | ||
|
||
private static Runnable runnable(final StudyService studyService) { | ||
return new Runnable() { | ||
|
||
@Transactional | ||
public void run() { | ||
LOGGER.debug(LocalDateTime.now() + " : " + "start moamoa scheduled task!"); | ||
studyService.autoCloseStudies(); | ||
} | ||
return () -> { | ||
log.debug("{} : start moamoa scheduled task!", LocalDateTime.now()); | ||
studyService.autoUpdateStatus(); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍