Sort approvals in REST endpoints and approval table

Document REST endpoints to return approvals within a given list by
timestamp, although the timestamp is not exposed. Sort labels by
corresponding ApprovalCategory position.

On the client side, sort users by the owner first, followed by users
with nonzero votes.

Change-Id: I68cd21e4a62b76bd7de2bf1dd1e18e8675dd34db
This commit is contained in:
Dave Borowitz
2013-02-14 12:58:28 -08:00
parent ed5364b937
commit 0f697c84d0
6 changed files with 91 additions and 19 deletions

View File

@@ -79,8 +79,8 @@ public class ReviewerJson {
PatchSet.Id psId = ctl.getChange().currentPatchSetId();
if (approvals == null) {
approvals = db.get().patchSetApprovals()
.byPatchSetUser(psId, out._id).toList();
approvals = ChangeData.sortApprovals(db.get().patchSetApprovals()
.byPatchSetUser(psId, out._id));
}
FunctionState fs = functionState.create(ctl, psId, approvals);
@@ -88,7 +88,7 @@ public class ReviewerJson {
CategoryFunction.forCategory(at.getCategory()).run(at, fs);
}
out.approvals = Maps.newHashMapWithExpectedSize(approvals.size());
out.approvals = Maps.newTreeMap(LabelOrdering.create(approvalTypes));
for (PatchSetApproval ca : approvals) {
for (PermissionRange pr : ctl.getLabelRanges()) {
if (!pr.isEmpty()) {