Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12048] Relax read notif verification for migration verification script #12937

Merged
merged 4 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/java/teammates/client/scripts/sql/SeedDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected void persistAdditionalData() {
String accountRequestEmail = String.format("Account Email %s", i);
String accountRequestInstitute = String.format("Account Institute %s", i);
AccountRequest accountRequest = AccountRequestAttributes
.builder(accountRequestName, accountRequestEmail, accountRequestInstitute)
.builder(accountRequestEmail, accountRequestInstitute, accountRequestName)
.withRegisteredAt(Instant.now()).build().toEntity();

String accountGoogleId = String.format("Account Google ID %s", i);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package teammates.client.scripts.sql;

// CHECKSTYLE.OFF:ImportOrder
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
Expand All @@ -17,7 +13,6 @@

import teammates.common.util.HibernateUtil;
import teammates.storage.entity.Account;
import teammates.storage.sqlentity.ReadNotification;

/**
* Class for verifying account attributes.
Expand Down Expand Up @@ -87,18 +82,25 @@ public boolean equals(teammates.storage.sqlentity.Account sqlEntity, Account dat
return false;
}

Map<String, Instant> datastoreReadNotifications = datastoreEntity.getReadNotifications();
List<ReadNotification> sqlReadNotifications = sqlEntity.getReadNotifications();
return true;

List<Instant> datastoreEndTimes = new ArrayList<Instant>(datastoreReadNotifications.values());
Collections.sort(datastoreEndTimes);
// Not verifying read notification as current datastore implementation does not remove notifications
// that have been deleted from account entities. During migration, the notification will not be
// migrated since it is deleted and read notification will fail during migration (foreign key error)
// causing the verification to fail

List<Instant> sqlEndTimes = new ArrayList<>();
for (ReadNotification sqlReadNotification : sqlReadNotifications) {
sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime());
}
Collections.sort(sqlEndTimes);
// Map<String, Instant> datastoreReadNotifications = datastoreEntity.getReadNotifications();
// List<ReadNotification> sqlReadNotifications = sqlEntity.getReadNotifications();

// List<Instant> datastoreEndTimes = new ArrayList<Instant>(datastoreReadNotifications.values());
// Collections.sort(datastoreEndTimes);

// List<Instant> sqlEndTimes = new ArrayList<>();
// for (ReadNotification sqlReadNotification : sqlReadNotifications) {
// sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime());
// }
// Collections.sort(sqlEndTimes);

return datastoreEndTimes.equals(sqlEndTimes);
// return datastoreEndTimes.equals(sqlEndTimes);
}
}
Loading