Skip to content

Commit

Permalink
[fix] #96 answer 분기처리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoo0419 committed Jun 7, 2024
1 parent 600de26 commit 09cae22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ List<Answer> findAllByProfileInAndCreatedAtBetweenOrderByCreatedAt(

Boolean existsByQuestion(Question question);

Boolean existsByProfile(Profile profile);

@Query(value="select new com.telepigeon.server.dto.answer.RankAnswerDto(a.question.keyword, avg(a.emotion)) " +
"from Answer a where a.profile = :profile and a.question.keyword is not null and a.createdAt between :startTime and :endTime " +
"group by a.question.keyword order by avg(a.emotion) desc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public Answer findFirstByProfile(final Profile profile){
);
}

public boolean existsByProfile(final Profile profile){
return answerRepository.existsByProfile(profile);
}

public Answer findByQuestion(final Question question){
return answerRepository.findByQuestion(question)
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ public RoomListDto.RoomDto createRoomDto(final User user, final Room room) {
);
}
Profile opponentProfile = profileRetriever.findByUserNotAndRoom(user, room);
Answer myAnswer = answerRetriever.findFirstByProfile(myProfile);
Answer opponentAnswer = answerRetriever.findFirstByProfile(opponentProfile);
String opponentRelation = opponentProfile.getRelation() != null ? opponentProfile.getRelation().getContent() : "-";
boolean myState = myAnswer.getContent() != null;
boolean opponentState = opponentAnswer.getContent() != null;
boolean myState = answerRetriever.existsByProfile(myProfile);
boolean opponentState = answerRetriever.existsByProfile(opponentProfile);

// 감정 측정 시 업데이트
// 감정 측정 시 업데이트
emotion = getEmotion(opponentProfile.getEmotion());

if (myState && opponentState) {
Expand Down

0 comments on commit 09cae22

Please sign in to comment.