From d88ceb00db39a8c8621d04a907021b6847d84562 Mon Sep 17 00:00:00 2001 From: EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Date: Mon, 15 Apr 2024 22:15:35 +0800 Subject: [PATCH 1/4] feat: add order-by --- src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java b/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java index 310b78e6239..499781a314e 100644 --- a/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java +++ b/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java @@ -84,7 +84,9 @@ public List getPendingAccountRequests() { CriteriaBuilder cb = HibernateUtil.getCriteriaBuilder(); CriteriaQuery cr = cb.createQuery(AccountRequest.class); Root root = cr.from(AccountRequest.class); - cr.select(root).where(cb.equal(root.get("status"), AccountRequestStatus.PENDING)); + cr.select(root) + .where(cb.equal(root.get("status"), AccountRequestStatus.PENDING)) + .orderBy(cb.desc(root.get("createdAt"))); TypedQuery query = HibernateUtil.createQuery(cr); return query.getResultList(); From b74b90bfcb5dd29ca2618e0d7ec7b9c4a616ab54 Mon Sep 17 00:00:00 2001 From: EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Date: Mon, 15 Apr 2024 22:43:10 +0800 Subject: [PATCH 2/4] fix: fix failing test case --- .../ui/webapi/GetAccountRequestsActionIT.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java index 565fda387a5..3f51727fc93 100644 --- a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java +++ b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java @@ -88,16 +88,19 @@ public void testExecute() { assertEquals(2, arData.size()); // account request 1 - assertEquals(arData.get(0).getEmail(), accountRequest1.getEmail()); - assertEquals(arData.get(0).getInstitute(), accountRequest1.getInstitute()); - assertEquals(arData.get(0).getName(), accountRequest1.getName()); - assertEquals(arData.get(0).getRegistrationKey(), accountRequest1.getRegistrationKey()); + assertEquals(arData.get(1).getEmail(), accountRequest1.getEmail()); + assertEquals(arData.get(1).getInstitute(), accountRequest1.getInstitute()); + assertEquals(arData.get(1).getName(), accountRequest1.getName()); + assertEquals(arData.get(1).getRegistrationKey(), accountRequest1.getRegistrationKey()); // account request 2 - assertEquals(arData.get(1).getEmail(), accountRequest2.getEmail()); - assertEquals(arData.get(1).getInstitute(), accountRequest2.getInstitute()); - assertEquals(arData.get(1).getName(), accountRequest2.getName()); - assertEquals(arData.get(1).getRegistrationKey(), accountRequest2.getRegistrationKey()); + assertEquals(arData.get(0).getEmail(), accountRequest2.getEmail()); + assertEquals(arData.get(0).getInstitute(), accountRequest2.getInstitute()); + assertEquals(arData.get(0).getName(), accountRequest2.getName()); + assertEquals(arData.get(0).getRegistrationKey(), accountRequest2.getRegistrationKey()); + + // Assert sorted in descending order + assertTrue(arData.get(0).getCreatedAt() < arData.get(1).getCreatedAt()); } @Override From c8c7e6f59382627e645d85a41a63a8e6f37fb8be Mon Sep 17 00:00:00 2001 From: EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Date: Mon, 15 Apr 2024 23:01:08 +0800 Subject: [PATCH 3/4] fix: add missing created-at field --- src/it/resources/data/typicalDataBundle.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/it/resources/data/typicalDataBundle.json b/src/it/resources/data/typicalDataBundle.json index 887488e829d..4c97cca8512 100644 --- a/src/it/resources/data/typicalDataBundle.json +++ b/src/it/resources/data/typicalDataBundle.json @@ -73,7 +73,8 @@ "name": "Instructor 1", "email": "instr1@teammates.tmt", "institute": "TEAMMATES Test Institute 1", - "registeredAt": "2010-02-14T00:00:00Z" + "registeredAt": "2010-02-14T00:00:00Z", + "createdAt": "2011-02-01T00:00:00Z" }, "instructor2": { "id": "00000000-0000-4000-8000-000000000102", From 4d0b2fddc0be8c34455ddebe2bdf9a9ccc2a1b7e Mon Sep 17 00:00:00 2001 From: EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Date: Mon, 15 Apr 2024 23:12:09 +0800 Subject: [PATCH 4/4] fix: test case comment --- .../teammates/it/ui/webapi/GetAccountRequestsActionIT.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java index 3f51727fc93..feecca65747 100644 --- a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java +++ b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java @@ -87,7 +87,7 @@ public void testExecute() { assertEquals(2, arData.size()); - // account request 1 + // account request 1 (with the most recent created_at) assertEquals(arData.get(1).getEmail(), accountRequest1.getEmail()); assertEquals(arData.get(1).getInstitute(), accountRequest1.getInstitute()); assertEquals(arData.get(1).getName(), accountRequest1.getName()); @@ -98,9 +98,6 @@ public void testExecute() { assertEquals(arData.get(0).getInstitute(), accountRequest2.getInstitute()); assertEquals(arData.get(0).getName(), accountRequest2.getName()); assertEquals(arData.get(0).getRegistrationKey(), accountRequest2.getRegistrationKey()); - - // Assert sorted in descending order - assertTrue(arData.get(0).getCreatedAt() < arData.get(1).getCreatedAt()); } @Override