Skip to content

Commit

Permalink
Merge pull request #169 from hyeonahhh/main
Browse files Browse the repository at this point in the history
fix: count가 0일때 0 리턴으로 변경
  • Loading branch information
hyeonahhh authored Jul 21, 2024
2 parents 334bf34 + 2063cbb commit b27155d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private Report calculateAndSetCategoryRates(Report report, Map<ChecklistQuestion
continue;
}
List<ChecklistAnswer> answers = categorizedAnswers.get(category);
System.out.println("############" + answers);
Float categoryRate = calculateAverage(answers);

if (categoryRate == null) {
Expand Down Expand Up @@ -143,16 +142,17 @@ private Float calculateAverage(List<ChecklistAnswer> answers) {
}
Float total = 0f;
int count = 0;
if (answers != null) {
for (ChecklistAnswer answer : answers) {
if (answer.getQuestionId().getAnswerType() == ChecklistQuestionType.SCORE) {
total += Float.parseFloat(answer.getAnswer());
count++;
}
for (ChecklistAnswer answer : answers) {
if (answer.getQuestionId().getAnswerType() == ChecklistQuestionType.SCORE) {
System.out.println("questionId : " + answer.getQuestionId().getQuestionId() + " answerType : " + answer.getQuestionId().getAnswerType());
total += Float.parseFloat(answer.getAnswer());
count++;
}
return total / count;
}
return total;
if (count == 0) {
return total;
}
return total / count;
}

public String setRandomKeyword(Float rate){
Expand Down

0 comments on commit b27155d

Please sign in to comment.