Skip to content

Commit

Permalink
[#12048] Delete redundant index (#13095)
Browse files Browse the repository at this point in the history
* Add null check

* Delete index
  • Loading branch information
FergusMok authored Apr 24, 2024
1 parent 8c71ecf commit 1d7fb0c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 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
4 changes: 1 addition & 3 deletions src/main/java/teammates/storage/sqlentity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
* Represents a User.
*/
@Entity
@Table(name = "Users", uniqueConstraints = {
@UniqueConstraint(name = "Unique email and courseId", columnNames = { "email", "courseId" })
})
@Table(name = "Users")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class User extends BaseEntity {
@Id
Expand Down

0 comments on commit 1d7fb0c

Please sign in to comment.