Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.gpt.geumpumtabackend.study.dto.response;

public record StudySessionResponse(Long totalStudySession, boolean isStudying) {
import java.time.LocalDateTime;

public static StudySessionResponse of(Long totalStudySession, boolean isStudying) {
return new StudySessionResponse(totalStudySession, isStudying);
public record StudySessionResponse(Long totalStudySession, boolean isStudying, LocalDateTime startTime) {

public static StudySessionResponse of(Long totalStudySession, boolean isStudying, LocalDateTime startTime) {
return new StudySessionResponse(totalStudySession, isStudying, startTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ public class StudySessionService {
public StudySessionResponse getTodayStudySession(Long userId) {
LocalDateTime startOfDay = LocalDate.now().atStartOfDay();
LocalDateTime now = LocalDateTime.now();
boolean isStudying = studySessionRepository.findByUser_IdAndStatus(userId, StudyStatus.STARTED).isPresent();
StudySession activeSession = studySessionRepository.findByUser_IdAndStatus(userId, StudyStatus.STARTED)
.orElse(null);
boolean isStudying = activeSession != null;
LocalDateTime startTime = isStudying ? activeSession.getStartTime() : null;
Long totalStudySession = studySessionRepository.sumCompletedStudySessionByUserId(userId, startOfDay, now);
return StudySessionResponse.of(totalStudySession,isStudying);
return StudySessionResponse.of(totalStudySession, isStudying, startTime);
}

/*
Expand Down
Loading