Removed DESC keyword from several ORM Queries

In order to better support non-relational DBs that do not support
sorting in a descending order, I have removed the DESC keyword from
several of the ORM queries in which is was present.

Change-Id: Iac9cbc43a62e7e652f721cacf223e8161eb4a280
This commit is contained in:
Jeff Schumacher
2010-05-28 16:11:38 -07:00
parent 2366d781b3
commit 611e4c1520
4 changed files with 24 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -49,11 +50,18 @@ class AgreementInfoFactory extends Handler<AgreementInfo> {
public AgreementInfo call() throws Exception {
final List<AccountAgreement> userAccepted =
db.accountAgreements().byAccount(user.getAccountId()).toList();
Collections.reverse(userAccepted);
final List<AccountGroupAgreement> groupAccepted =
new ArrayList<AccountGroupAgreement>();
for (final AccountGroup.Id groupId : user.getEffectiveGroups()) {
groupAccepted.addAll(db.accountGroupAgreements().byGroup(groupId)
.toList());
final List<AccountGroupAgreement> temp =
db.accountGroupAgreements().byGroup(groupId).toList();
Collections.reverse(temp);
groupAccepted.addAll(temp);
}
final Map<ContributorAgreement.Id, ContributorAgreement> agreements =

View File

@@ -25,6 +25,6 @@ public interface AccountAgreementAccess extends
@PrimaryKey("key")
AccountAgreement get(AccountAgreement.Key key) throws OrmException;
@Query("WHERE key.accountId = ? ORDER BY acceptedOn DESC")
@Query("WHERE key.accountId = ? ORDER BY acceptedOn")
ResultSet<AccountAgreement> byAccount(Account.Id id) throws OrmException;
}

View File

@@ -25,7 +25,7 @@ public interface AccountGroupAgreementAccess extends
@PrimaryKey("key")
AccountGroupAgreement get(AccountGroupAgreement.Key key) throws OrmException;
@Query("WHERE key.groupId = ? ORDER BY acceptedOn DESC")
@Query("WHERE key.groupId = ? ORDER BY acceptedOn")
ResultSet<AccountGroupAgreement> byGroup(AccountGroup.Id id)
throws OrmException;
}

View File

@@ -291,8 +291,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
ContributorAgreement bestCla = null;
OUTER: for (AccountGroup.Id groupId : currentUser.getEffectiveGroups()) {
for (final AccountGroupAgreement a : db.accountGroupAgreements().byGroup(
groupId)) {
final List<AccountGroupAgreement> temp =
db.accountGroupAgreements().byGroup(groupId).toList();
Collections.reverse(temp);
for (final AccountGroupAgreement a : temp) {
final ContributorAgreement cla =
db.contributorAgreements().get(a.getAgreementId());
if (cla == null) {
@@ -306,8 +310,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
}
if (bestAgreement == null) {
for (final AccountAgreement a : db.accountAgreements().byAccount(
currentUser.getAccountId()).toList()) {
final List<AccountAgreement> temp =
db.accountAgreements().byAccount(currentUser.getAccountId()).toList();
Collections.reverse(temp);
for (final AccountAgreement a : temp) {
final ContributorAgreement cla =
db.contributorAgreements().get(a.getAgreementId());
if (cla == null) {