How to get reviewer for a merge proposal using lauchpadlib API?

Asked by markpitchless on 2012-04-11

I'm using to launchpadlib to grab active reviews for our team. This gets me all sorts of useful info but I can't work out how to find the person who is doing the review, the reviewer. I can find who submitted the review. When I look at the LP web site for the merge I can see the reviewer listed in a table. Have looked through all the data returned and the rest interface docs but can't seem to see it.

How can I get the reviewer via the API?

In case it helps this is how I'm getting the merge proposals:

 lp = Launchpad.login_with( ... )
 team = lp.people( 'teamname' )
 props = team.getMergeProposals(status='Needs review')
 for mp in props:
     # how do i get reveiwer out of mp?

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Francis J. Lacoste
Solved:
2012-04-11
Last query:
2012-04-11
Last reply:
2012-04-11
markpitchless (markpitchless) said : #1

Ok, to answer my own question I think I found it. The reviewers are found via votes for them, at most one per reviewer.
https://launchpad.net/+apidoc/1.0.html#code_review_vote_reference

Expanding the example code:

 lp = Launchpad.login_with( ... )
 team = lp.people( 'teamname' )
 props = team.getMergeProposals(status='Needs review')
 for mp in props:
     for vote in mp.votes
         print vote.reviewer

Best Francis J. Lacoste (flacoste) said : #2

You can find the reference documentation for the API at the following link:
https://launchpad.net/+apidoc/devel.html

(You might want to read https://help.launchpad.net/API/launchpadlib#Getting_help to see how to translate from that documentation to launchpadlib conventions.)

The branch_merge_proposal object has a reviewer_link attribute (will be .reviewer in launchpadlib) which contains the person who accepted the review. If the review wasn't accepted (they hit claim review in the UI, or made a comment on the review), it will be None. (https://launchpad.net/+apidoc/devel.html#branch_merge_proposal)

The tables you are seeing on the web page is made of code_review_vote_reference objects and can be accessed through the votes_collection_link (.votes in lplib). ( https://launchpad.net/+apidoc/devel.html#code_review_vote_reference) These objects also has a reviewer_link.

Hope that helps.

markpitchless (markpitchless) said : #3

Thanks for the complete answer Francis. I had basically got there, took a while to realise that reviewers get voted in!

markpitchless (markpitchless) said : #4

Thanks Francis J. Lacoste, that solved my question.