Merge "Show granted date for labels/all when using /changes/-api."

This commit is contained in:
Shawn Pearce
2013-05-10 17:42:03 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 3 deletions

View File

@@ -2068,6 +2068,8 @@ In addition `ApprovalInfo` has the following fields:
The vote that the user has given for the label. If present and zero, the
user is permitted to vote on the label. If absent, the user is not
permitted to vote on that label.
|`date` |optional|
The time and date describing when the approval was made.
|===========================
[[change-info]]

View File

@@ -470,16 +470,18 @@ public class ChangeJson {
continue;
}
Integer value;
Timestamp date = null;
PatchSetApproval psa = current.get(accountId, lt.getName());
if (psa != null) {
value = Integer.valueOf(psa.getValue());
date = psa.getGranted();
} else {
// Either the user cannot vote on this label, or there just wasn't a
// dummy approval for this label. Explicitly check whether the user
// can vote on this label.
value = labelNormalizer.canVote(ctl, lt, accountId) ? 0 : null;
}
e.getValue().addApproval(approvalInfo(accountId, value));
e.getValue().addApproval(approvalInfo(accountId, value, date));
}
}
}
@@ -523,7 +525,7 @@ public class ChangeJson {
if (detailed) {
for (String name : labels.keySet()) {
ApprovalInfo ai = approvalInfo(accountId, 0);
ApprovalInfo ai = approvalInfo(accountId, 0, null);
byLabel.put(name, ai);
labels.get(name).addApproval(ai);
}
@@ -538,6 +540,7 @@ public class ChangeJson {
ApprovalInfo info = byLabel.get(type.getName());
if (info != null) {
info.value = Integer.valueOf(val);
info.date = psa.getGranted();
}
LabelInfo li = labels.get(type.getName());
@@ -562,9 +565,10 @@ public class ChangeJson {
return labels;
}
private ApprovalInfo approvalInfo(Account.Id id, Integer value) {
private ApprovalInfo approvalInfo(Account.Id id, Integer value, Timestamp date) {
ApprovalInfo ai = new ApprovalInfo(id);
ai.value = value;
ai.date = date;
accountLoader.put(ai);
return ai;
}
@@ -918,6 +922,7 @@ public class ChangeJson {
static class ApprovalInfo extends AccountInfo {
Integer value;
Timestamp date;
ApprovalInfo(Account.Id id) {
super(id);