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:
@@ -25,6 +25,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -49,11 +50,18 @@ class AgreementInfoFactory extends Handler<AgreementInfo> {
|
|||||||
public AgreementInfo call() throws Exception {
|
public AgreementInfo call() throws Exception {
|
||||||
final List<AccountAgreement> userAccepted =
|
final List<AccountAgreement> userAccepted =
|
||||||
db.accountAgreements().byAccount(user.getAccountId()).toList();
|
db.accountAgreements().byAccount(user.getAccountId()).toList();
|
||||||
|
|
||||||
|
Collections.reverse(userAccepted);
|
||||||
|
|
||||||
final List<AccountGroupAgreement> groupAccepted =
|
final List<AccountGroupAgreement> groupAccepted =
|
||||||
new ArrayList<AccountGroupAgreement>();
|
new ArrayList<AccountGroupAgreement>();
|
||||||
for (final AccountGroup.Id groupId : user.getEffectiveGroups()) {
|
for (final AccountGroup.Id groupId : user.getEffectiveGroups()) {
|
||||||
groupAccepted.addAll(db.accountGroupAgreements().byGroup(groupId)
|
final List<AccountGroupAgreement> temp =
|
||||||
.toList());
|
db.accountGroupAgreements().byGroup(groupId).toList();
|
||||||
|
|
||||||
|
Collections.reverse(temp);
|
||||||
|
|
||||||
|
groupAccepted.addAll(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<ContributorAgreement.Id, ContributorAgreement> agreements =
|
final Map<ContributorAgreement.Id, ContributorAgreement> agreements =
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ public interface AccountAgreementAccess extends
|
|||||||
@PrimaryKey("key")
|
@PrimaryKey("key")
|
||||||
AccountAgreement get(AccountAgreement.Key key) throws OrmException;
|
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;
|
ResultSet<AccountAgreement> byAccount(Account.Id id) throws OrmException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public interface AccountGroupAgreementAccess extends
|
|||||||
@PrimaryKey("key")
|
@PrimaryKey("key")
|
||||||
AccountGroupAgreement get(AccountGroupAgreement.Key key) throws OrmException;
|
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)
|
ResultSet<AccountGroupAgreement> byGroup(AccountGroup.Id id)
|
||||||
throws OrmException;
|
throws OrmException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,8 +291,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
|
|||||||
ContributorAgreement bestCla = null;
|
ContributorAgreement bestCla = null;
|
||||||
|
|
||||||
OUTER: for (AccountGroup.Id groupId : currentUser.getEffectiveGroups()) {
|
OUTER: for (AccountGroup.Id groupId : currentUser.getEffectiveGroups()) {
|
||||||
for (final AccountGroupAgreement a : db.accountGroupAgreements().byGroup(
|
final List<AccountGroupAgreement> temp =
|
||||||
groupId)) {
|
db.accountGroupAgreements().byGroup(groupId).toList();
|
||||||
|
|
||||||
|
Collections.reverse(temp);
|
||||||
|
|
||||||
|
for (final AccountGroupAgreement a : temp) {
|
||||||
final ContributorAgreement cla =
|
final ContributorAgreement cla =
|
||||||
db.contributorAgreements().get(a.getAgreementId());
|
db.contributorAgreements().get(a.getAgreementId());
|
||||||
if (cla == null) {
|
if (cla == null) {
|
||||||
@@ -306,8 +310,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bestAgreement == null) {
|
if (bestAgreement == null) {
|
||||||
for (final AccountAgreement a : db.accountAgreements().byAccount(
|
final List<AccountAgreement> temp =
|
||||||
currentUser.getAccountId()).toList()) {
|
db.accountAgreements().byAccount(currentUser.getAccountId()).toList();
|
||||||
|
|
||||||
|
Collections.reverse(temp);
|
||||||
|
|
||||||
|
for (final AccountAgreement a : temp) {
|
||||||
final ContributorAgreement cla =
|
final ContributorAgreement cla =
|
||||||
db.contributorAgreements().get(a.getAgreementId());
|
db.contributorAgreements().get(a.getAgreementId());
|
||||||
if (cla == null) {
|
if (cla == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user