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

[#11878] Add sort by created_at for getAllPendingRequests #13038

Merged
merged 4 commits into from
Apr 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ 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());
// 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());
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());
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/it/resources/data/typicalDataBundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public List<AccountRequest> getPendingAccountRequests() {
CriteriaBuilder cb = HibernateUtil.getCriteriaBuilder();
CriteriaQuery<AccountRequest> cr = cb.createQuery(AccountRequest.class);
Root<AccountRequest> 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<AccountRequest> query = HibernateUtil.createQuery(cr);
return query.getResultList();
Expand Down
Loading