Skip to content

Commit

Permalink
Add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
FergusMok committed Apr 24, 2024
1 parent 296ae55 commit a5a07c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ private void migrateFeedbackQuestion(teammates.storage.sqlentity.FeedbackSession
oldResponses = ofy().load().type(FeedbackResponse.class)
.filter("feedbackQuestionId", oldQuestion.getId()).list();
}

if (oldResponses == null || oldResponses.size() == 0) {
log(String.format("No responses found for question %s %s in course %s", oldQuestion.getId(), oldQuestion.getQuestionNumber(), newSession.getCourse().getId()));
return;
}


for (FeedbackResponse oldResponse : oldResponses) {
Section newGiverSection = sectionNameToSectionMap.get(oldResponse.getGiverSection());
Section newRecipientSection = sectionNameToSectionMap.get(oldResponse.getRecipientSection());
Expand All @@ -340,6 +347,11 @@ private void migrateFeedbackResponse(teammates.storage.sqlentity.FeedbackQuestio

// cascade migrate response comments
List<FeedbackResponseComment> oldComments = responseIdToCommentsMap.get(oldResponse.getId());
if (oldComments == null) {
log(String.format("No comments found for response %s in course %s", oldResponse.getId(), oldResponse.getCourseId()));
return;
}

for (FeedbackResponseComment oldComment : oldComments) {
migrateFeedbackResponseComment(newResponse, oldComment, newGiverSection, newRecipientSection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ private void migrateFeedbackQuestion(teammates.storage.sqlentity.FeedbackSession
.filter("feedbackQuestionId", oldQuestion.getId()).list();
}
log(String.format("Feedback question %d has %d responses associated with it", oldQuestion.getQuestionNumber(), oldResponses.size()));

if (oldResponses == null || oldResponses.size() == 0) {
log(String.format("No responses found for question %s %s in course %s", oldQuestion.getId(), oldQuestion.getQuestionNumber(), newSession.getCourse().getId()));
return;
}

for (FeedbackResponse oldResponse : oldResponses) {
Section newGiverSection = sectionNameToSectionMap.get(oldResponse.getGiverSection());
Section newRecipientSection = sectionNameToSectionMap.get(oldResponse.getRecipientSection());
Expand All @@ -341,6 +347,11 @@ private void migrateFeedbackResponse(teammates.storage.sqlentity.FeedbackQuestio

// cascade migrate response comments
List<FeedbackResponseComment> oldComments = responseIdToCommentsMap.get(oldResponse.getId());
if (oldComments == null) {
log(String.format("No comments found for response %s in course %s", oldResponse.getId(), oldResponse.getCourseId()));
return;
}

for (FeedbackResponseComment oldComment : oldComments) {
migrateFeedbackResponseComment(newResponse, oldComment, newGiverSection, newRecipientSection);
}
Expand Down

0 comments on commit a5a07c4

Please sign in to comment.