From 04c1affbee6bf986ecb2f59d6badf3a3847a587d Mon Sep 17 00:00:00 2001 From: nicolascwy <25302138+NicolasCwy@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:49:52 +0800 Subject: [PATCH 1/4] Fix account requests with wrong field during seed --- src/client/java/teammates/client/scripts/sql/SeedDb.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/java/teammates/client/scripts/sql/SeedDb.java b/src/client/java/teammates/client/scripts/sql/SeedDb.java index 20d13ad5c67..b1462cc3f33 100644 --- a/src/client/java/teammates/client/scripts/sql/SeedDb.java +++ b/src/client/java/teammates/client/scripts/sql/SeedDb.java @@ -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, accountRequestName, accountRequestInstitute) .withRegisteredAt(Instant.now()).build().toEntity(); String accountGoogleId = String.format("Account Google ID %s", i); From ffcd45ffa9aede2ce1076b7119ddfd9eb854026b Mon Sep 17 00:00:00 2001 From: nicolascwy <25302138+NicolasCwy@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:53:43 +0800 Subject: [PATCH 2/4] Relax account attributes verification --- .../scripts/sql/VerifyAccountAttributes.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java index b2f03532968..0ee299a6511 100644 --- a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java +++ b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java @@ -87,18 +87,23 @@ public boolean equals(teammates.storage.sqlentity.Account sqlEntity, Account dat return false; } - Map datastoreReadNotifications = datastoreEntity.getReadNotifications(); - List sqlReadNotifications = sqlEntity.getReadNotifications(); + return true; - List datastoreEndTimes = new ArrayList(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 + // Map datastoreReadNotifications = datastoreEntity.getReadNotifications(); + // List sqlReadNotifications = sqlEntity.getReadNotifications(); - List sqlEndTimes = new ArrayList<>(); - for (ReadNotification sqlReadNotification : sqlReadNotifications) { - sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime()); - } - Collections.sort(sqlEndTimes); + // List datastoreEndTimes = new ArrayList(datastoreReadNotifications.values()); + // Collections.sort(datastoreEndTimes); + + // List sqlEndTimes = new ArrayList<>(); + // for (ReadNotification sqlReadNotification : sqlReadNotifications) { + // sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime()); + // } + // Collections.sort(sqlEndTimes); - return datastoreEndTimes.equals(sqlEndTimes); + // return datastoreEndTimes.equals(sqlEndTimes); } } From 45eb2d1c8f10f7b4d26fa7d95956468061dd7bd6 Mon Sep 17 00:00:00 2001 From: Nicolas Chang <25302138+NicolasCwy@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:06:21 +0800 Subject: [PATCH 3/4] Fix lint errors --- .../client/scripts/sql/VerifyAccountAttributes.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java index 0ee299a6511..b53f684640c 100644 --- a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java +++ b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java @@ -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; @@ -17,7 +13,6 @@ import teammates.common.util.HibernateUtil; import teammates.storage.entity.Account; -import teammates.storage.sqlentity.ReadNotification; /** * Class for verifying account attributes. @@ -89,9 +84,11 @@ public boolean equals(teammates.storage.sqlentity.Account sqlEntity, Account dat return true; - // 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 + // 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 + // Map datastoreReadNotifications = datastoreEntity.getReadNotifications(); // List sqlReadNotifications = sqlEntity.getReadNotifications(); From 9f2a050b3462892a91c3f52a2556057a4b356522 Mon Sep 17 00:00:00 2001 From: Nicolas Chang <25302138+NicolasCwy@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:40:53 +0800 Subject: [PATCH 4/4] Fix order of account request variables --- src/client/java/teammates/client/scripts/sql/SeedDb.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/java/teammates/client/scripts/sql/SeedDb.java b/src/client/java/teammates/client/scripts/sql/SeedDb.java index b1462cc3f33..40185c120de 100644 --- a/src/client/java/teammates/client/scripts/sql/SeedDb.java +++ b/src/client/java/teammates/client/scripts/sql/SeedDb.java @@ -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(accountRequestEmail, accountRequestName, accountRequestInstitute) + .builder(accountRequestEmail, accountRequestInstitute, accountRequestName) .withRegisteredAt(Instant.now()).build().toEntity(); String accountGoogleId = String.format("Account Google ID %s", i);