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 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 user is permitted to vote on the label. If absent, the user is not
permitted to vote on that label. permitted to vote on that label.
|`date` |optional|
The time and date describing when the approval was made.
|=========================== |===========================
[[change-info]] [[change-info]]

View File

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