Skip to content

Commit

Permalink
Merge pull request #97 from dnd-side-project/dev
Browse files Browse the repository at this point in the history
release 0.0.7
  • Loading branch information
rlacksgus97 authored Feb 29, 2024
2 parents f1fc0f7 + c2f4757 commit e79cb81
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@AllArgsConstructor
Expand Down Expand Up @@ -48,14 +50,12 @@ public static GetSurveyResponse from(Survey survey, List<Question> questions) {
}

private static List<SingleQuestionAndAnswer> pairQuestionAndAnswer(Survey survey, List<Question> questions) {
var size = questions.size();
Map<String, Question> questionMap = new HashMap<>();
questions.forEach(question -> questionMap.put(question.getId(), question));

var answers = survey.getAnswers();
List<SingleQuestionAndAnswer> questionAndAnswerList = new ArrayList<>();
for (int i = 0; i < size; i++) {
var question = questions.get(i);
var answer = answers.get(i);
questionAndAnswerList.add(SingleQuestionAndAnswer.from(question, answer));
}
answers.forEach(answer -> questionAndAnswerList.add(SingleQuestionAndAnswer.from(questionMap.get(answer.getQuestion().getId()), answer)));
return questionAndAnswerList;
}

Expand Down

0 comments on commit e79cb81

Please sign in to comment.