feat: 有效学习时间不足10分钟不计入总学习时间
- StudySessionsEntity: 新增 MIN_EFFECTIVE_TIME_SECONDS 常量, endedStudySession() 中检查 effectiveTime,不足则清零 - StudySessionsService: endedStudySession 返回类型从 void 改为 String
This commit is contained in:
@@ -132,6 +132,11 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有效学习时间的最小阈值(秒),低于此值不计入总学习时间
|
||||||
|
*/
|
||||||
|
private static final double MIN_EFFECTIVE_TIME_SECONDS = 10 * 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束会话
|
* 结束会话
|
||||||
*/
|
*/
|
||||||
@@ -140,7 +145,12 @@ public class StudySessionsEntity extends BaseEntity implements Serializable {
|
|||||||
log.warn("不应出现的情况:结束了一个状态为【{}】的学习会话",this.getSessionState());
|
log.warn("不应出现的情况:结束了一个状态为【{}】的学习会话",this.getSessionState());
|
||||||
}else {
|
}else {
|
||||||
if (this.getSessionState().equals(StudySessionStateEnum.ONGOING.name())) {
|
if (this.getSessionState().equals(StudySessionStateEnum.ONGOING.name())) {
|
||||||
this.pausedStudySession(endTime);
|
this.pausedStudySession(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
if (this.getEffectiveTime() < MIN_EFFECTIVE_TIME_SECONDS) {
|
||||||
|
log.info("会话[{}]有效学习时间({}秒)不足10分钟,不计入总学习时间", this.getSessionNum(), this.getEffectiveTime());
|
||||||
|
this.setEffectiveTime(0);
|
||||||
|
this.setEffectivenessRatio(0);
|
||||||
}
|
}
|
||||||
this.setSessionState(StudySessionStateEnum.ENDED.name());
|
this.setSessionState(StudySessionStateEnum.ENDED.name());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public interface StudySessionsService extends IService<StudySessionsEntity> {
|
|||||||
|
|
||||||
ArrayList<String> getAllFragments(String sessionNum) throws ErrorParameterException;
|
ArrayList<String> getAllFragments(String sessionNum) throws ErrorParameterException;
|
||||||
|
|
||||||
void endedStudySession(String sessionNum, String content) throws ErrorParameterException;
|
String endedStudySession(String sessionNum, String content) throws ErrorParameterException;
|
||||||
|
|
||||||
void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException;
|
void pauseStudySession(String sessionNum, LocalDateTime endTime) throws ErrorParameterException, ServiceException;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user