Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 스케쥴러를 이용한 스터디 상태 자동 변경 * refactor: 스케줄러 로직 개선 * fix: 테스트 코드 수정 * refactor: 응답 값이 없는 경우 null 반환 * refactor: 메소드명 개선 및 Getter 추가 * refactor: 불필요한 메소드 제거 * refactor: log 개선 * refactor: 기존 메소드 활용 * refactor: `@Enumerated` 통일 * feat: 테스트 코드 수정 * refactor: StudyPlanner 수정 * feat: Study 불변식 검증 추가 * refactor: Auto에 Transactional 제거 * fix: 불필요한 Bean 제거 * test: 테스트 코드 개선
- Loading branch information
Showing
24 changed files
with
274 additions
and
193 deletions.
There are no files selected for viewing
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
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
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.