Skip to content

Commit

Permalink
Merge pull request #195 from SPACE-FOR-SPACE/refactor/#177
Browse files Browse the repository at this point in the history
유저 퀴즈 해결 시간 측정 기능 개선
  • Loading branch information
GSB0203 authored Nov 28, 2024
2 parents bed0d35 + e8f5d71 commit 5c93640
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public AiResponse chatTuneCreator(Long quizId, CreateChatRequest request, Long u
String content = responseMap.choices().get(0).message().content();
log.info("bot : " + content);
AiResponse botChat = aiResponseJsonParsing.jsonCreator(content, totalMapObject);
log.info("bot : " + responseMap.choices().get(0).message().content());
LocalDateTime lastChatTime = LocalDateTime.now();

if(request.type().toString().equals("HINT")) {
chatCreator.create(Chat.builder()
Expand All @@ -169,7 +171,6 @@ public AiResponse chatTuneCreator(Long quizId, CreateChatRequest request, Long u

if (state.get().getFirstTime() == null && botChat.isSuccess()) {
LocalDateTime firstChatTime = chatReader.findFirstChatTimeByState(state.get());
LocalDateTime lastChatTime = chatReader.findLastChatTimeByState(state.get());
Integer successCount = chatReader.countChatByQuiz(state.get());
stateUpdater.updateSuccess(state.get(), firstChatTime, lastChatTime, successCount);
}
Expand All @@ -192,7 +193,6 @@ public AiResponse chatTuneCreator(Long quizId, CreateChatRequest request, Long u

if (botChat.isSuccess()) {
LocalDateTime firstChatTime = chatReader.findFirstChatTimeByState(stateReader.findByQuizIdAndUserId(quiz, user).get());
LocalDateTime lastChatTime = chatReader.findLastChatTimeByState(stateReader.findByQuizIdAndUserId(quiz, user).get());
Integer successCount = chatReader.countChatByQuiz(stateReader.findByQuizIdAndUserId(quiz, user).get());
stateUpdater.updateSuccess(stateReader.findByQuizIdAndUserId(quiz, user).get(), firstChatTime, lastChatTime, successCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ public interface ChatRepository extends JpaRepository<Chat, Long> {
Integer countByState(State state);

Chat findFirstByStateOrderByCreatedAtAsc(State state);

Chat findFirstByStateOrderByCreatedAtDesc(State state);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,4 @@ public Integer countChatByQuiz(State state) {
public LocalDateTime findFirstChatTimeByState(State state) {
return chatRepository.findFirstByStateOrderByCreatedAtAsc(state).getCreatedAt();
}

public LocalDateTime findLastChatTimeByState(State state) {
return chatRepository.findFirstByStateOrderByCreatedAtDesc(state).getCreatedAt();
}
}

0 comments on commit 5c93640

Please sign in to comment.