Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] answer 분기처리 수정 #97

Merged
merged 1 commit into from
Jun 7, 2024
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
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
Loading