Skip to content

Commit

Permalink
[#12594] Fix deadline extensions update issue (#12601)
Browse files Browse the repository at this point in the history
* return new map to ensure updates are persisted to db

* make changes

* revert indentation

* add clear Objectify cache method to BaseTestCase

* fix checkstyle issues
  • Loading branch information
cedricongjh authored Nov 27, 2023
1 parent b4e3f42 commit 9d24d00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/teammates/logic/core/FeedbackSessionsLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
Expand Down Expand Up @@ -632,15 +633,17 @@ private void updateFeedbackSessionsDeadlinesForUser(String courseId, String emai
if (!instructorDeadlines.containsKey(emailAddress)) {
return;
}
deadlinesUpdater.accept(instructorDeadlines);
updateOptionsBuilder.withInstructorDeadlines(instructorDeadlines);
Map<String, Instant> newInstructorDeadlines = new HashMap<>(instructorDeadlines);
deadlinesUpdater.accept(newInstructorDeadlines);
updateOptionsBuilder.withInstructorDeadlines(newInstructorDeadlines);
} else {
Map<String, Instant> studentDeadlines = feedbackSession.getStudentDeadlines();
if (!studentDeadlines.containsKey(emailAddress)) {
return;
}
deadlinesUpdater.accept(studentDeadlines);
updateOptionsBuilder.withStudentDeadlines(studentDeadlines);
Map<String, Instant> newStudentDeadlines = new HashMap<>(studentDeadlines);
deadlinesUpdater.accept(newStudentDeadlines);
updateOptionsBuilder.withStudentDeadlines(newStudentDeadlines);
}
try {
fsDb.updateFeedbackSession(updateOptionsBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ public void testUpdateFeedbackSessionsStudentDeadlinesWithNewEmail() {

fsLogic.updateFeedbackSessionsStudentDeadlinesWithNewEmail(courseId, oldEmailAddress, newEmailAddress);

// Clear the Objectify cache to fetch the latest FeedbackSessions from the db
clearObjectifyCache();

assertTrue(fsLogic.getFeedbackSessionsForCourse(courseId)
.stream()
.noneMatch(feedbackSessionAttributes -> feedbackSessionAttributes.getStudentDeadlines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,8 @@ protected boolean doPutDocuments(DataBundle dataBundle) {
}
}

protected void clearObjectifyCache() {
ObjectifyService.ofy().clear();
}

}

0 comments on commit 9d24d00

Please sign in to comment.