Jump to content


Swarm API: Who approved the review


  • Please log in to reply
3 replies to this topic

#1 Clutchplate

Clutchplate

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 December 2018 - 12:00 AM

Apologies if this is not the right forum, I see API questions here, but there is also a general API forum...

Anyway, I'm having difficulty figuring out who approved a review once it is in the "approved" state. The participant votes all just reflect the upvotes. Is this not available in the API?

- Lutz

#2 P4Reg

P4Reg

    Advanced Member

  • Staff Moderators
  • 98 posts

Posted 19 December 2018 - 04:57 PM

You could use the Swarm api (https://www.perforce...arm-apidoc.html)

For example for review 14838, this will return a list of everyone who has approved the review :

curl -u  user:password "http://swarm-server/...state,approvals"
{"review":{"id":14838,"approvals":{"bruno":[0],"reg":[0],"swarm":[0]},"state":"approved"}}

That shows that the 3 users bruno, reg & swarm have all approved the review at some stage (in this case with it being moved to needs review after each approval). However it doesn't tell you who was the most recent person to approve (if it's only approved once then that might be enough).

The review history should be parsable for who approved it most recently with this kind of request:

curl -u user:password "http://swarm-server/api/v9/activity?stream=review-14838&fields=id,action,user"

{"activity":[{"id":11450,"action":"approved","user":"reg"},{"id":11449,"action":"requested further review of","user":"swarm"},{"id":11448,"action":"approved","user":"swarm"},{"id":11447,"action":"requested further review of","user":"bruno"},{"id":11446,"action":"approved","user":"bruno"},{"id":11445,"action":"requested further review of","user":"bruno"},{"id":11444,"action":"approved","user":"reg"},{"id":11443,"action":"approved","user":"reg"},{"id":11442,"action":"approved","user":"reg"},{"id":11441,"action":"requested further review of","user":"bruno"},{"id":11440,"action":"approved","user":"bruno"},{"id":11428,"action":"commented on","user":"reg"}],"lastSeen":11428}

The most recent person to approve will appear first in the returned json with an action of "approved" (in the above example that is "reg")

#3 Clutchplate

Clutchplate

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 December 2018 - 07:21 PM

Thanks for the reply.
I am using the Swarm API to retrieve this data. The API docs REALLY could use some TLC. I don't see "approvals" as a field anywhere, in fact none of the commands list the available fields for each command.

However, this does not work for my server.

When I issue
http://p4swarm/api/v9/reviews/4139412?fields=id,state,approvals

I get this back:
{"review":{"id":4139412,"state":"approved"}}

I get the same result if I leave off "approvals" from the fields. And leaving off the fields spec entirely, it also does not return approvals either.

The "version" command returns:
{"apiVersions":[1,1.1,1.2,2,3,4,5,6,7,8,9],"version":"SWARM\/2018.1\/1660025 (2018\/05\/09)","year":"2018"}

Is this something that can be configured on the server?

#4 Clutchplate

Clutchplate

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 19 December 2018 - 07:25 PM

The activity version does work for me, though, so I'll use that. Thanks!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users