Issue 2723: change detail REST API missing vote information for labels
Status:  Submitted
Owner: ----
Closed:  Jun 2014
Project Member Reported by zaro0508, Jun 19, 2014
The change detail REST API does not return all votes on a label. This issue seems like a regression because it seems to work ok on gerrit ver 2.8

Affected Version: master

What steps will reproduce the problem?
1. push a change to gerrit
2. have 2 users vote on that change (CR+1 and CR-1).
3. use the change detail api to retrieve the change info
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-change-detail

What is the expected output? What do you see instead?
I would expect the json to contain a "dislike" and "recommend" for "Code-Review" label.  What i see instead is that there is a dislike but no recommend.  "all" for code-review shows both the +1 and -1 scores from both users.

Please provide any additional information below.
I have attached the json from my test instance showing the problem. 

detail (15).json
2.8 KB   Download
Jun 20, 2014
Project Member #1 David.Os...@gmail.com
No. It works as designed. You are missing that those four votes per label are combined votes,
so obviously only one vote from four can be set:

* rejected
* approved
* disliked
* recommended

The priority for combined vote calculation is as following (from highest to lowest):

REJECTED > APPROVED > DISLIKED > RECOMMENDED

Or following the pattern "Talk is cheap, show me the code" [1]:

[1]
   if (score != 0) {
      if (score == type.getMin().getValue()) {
        label.rejected = accountLoader.get(accountId);
      } else if (score == type.getMax().getValue()) {
        label.approved = accountLoader.get(accountId);
      } else if (score < 0) {
        label.disliked = accountLoader.get(accountId);
        label.value = score;
      } else if (score > 0 && label.disliked == null) {
        label.recommended = accountLoader.get(accountId);
        label.value = score;
      }
    }

[1] https://gerrit.googlesource.com/gerrit/+/master/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeJson.java:430
Status: Invalid
Jun 20, 2014
Project Member #2 zaro0508
Ahh.  Is this documented anywhere?  if not then probably would be good to add documentation for it.  It was confusing to me because the sample response in the doc has both "dislike" and "recommend" for the code-review label.
Jun 22, 2014
Project Member #3 zaro0508
documentation add in change https://gerrit-review.googlesource.com/#/c/58020
Jun 22, 2014
Project Member #4 David.Os...@gmail.com
(No comment was entered for this change.)
Status: ChangeUnderReview
Jun 23, 2014
Project Member #5 David.Os...@gmail.com
(No comment was entered for this change.)
Status: Submitted