Here is a snippet of the Python code I'm using to access the extension. I
didn't want to include the whole script, as it would be too much detail.
But I can if others would prefer. Error handling is nonexistent at this
point in my script, so ignore obvious failure cases.
(Variables received by the time this code runs: years is an int, username
is a string and is just the base username, server_url is the server address
including https)
I am finding that I don't get any results for users who I query. I know
these users provided reviews 4 months ago on this test reviewboard
instance. But the script prints "0 reviews given."
I'm not asking for any debugging, but overall does this look like a sane
way to use the API to query the reviews given? The reviewboard Python API
code is so dynamic that it's hard to inspect at runtime.
utcnow = datetime.datetime.utcnow()
time_added_to = utcnow.isoformat()
utcbegin = utcnow - datetime.timedelta(weeks=years*52)
time_added_from = utcbegin.isoformat()
client = RBClient(server_url)
try:
root = client.get_root()
except AuthorizationError:
print('You are not logged in to the reviewboard API. '
'Enter your credentials:')
username = input('Username: ')
password = getpass('Password: ')
client.login(username, password)
root = client.get_root()
reviews_extension = None
for extension in root.get_extensions():
if extension.name == 'rb_reviews_api':
reviews_extension = extension
break
else:
print('No RB reviews API extension installed')
for username in usernames:
reviews_given = reviews_extension.get_reviews(
time_added_from=time_added_from,
time_added_to=time_added_to,
from_user=username,
)
review_count = 0
print('Fetching reviews given. This may take a while...')
for review_given in reviews_given.all_items:
review_count += 1
print('%d reviews given' % review_count)
On Mon, Nov 28, 2022 at 6:21 PM Adam Gross <[email protected]> wrote:
> Awesome, thank you so much!
>
> On Mon, Nov 28, 2022 at 4:22 PM David Trowbridge <[email protected]>
> wrote:
>
>> Adam,
>>
>> Because it comes from an extension, the endpoint is nested within the
>> extensions namespace at
>> /api/extensions/rb_reviews_api.extension.ReviewsAPI/reviews/
>>
>> It supports a ?from-user=<username> argument, as well as time-added-from=
>> and time-added-to= arguments (that work similar to the ones on other
>> endpoints).
>>
>> David
>>
>> On Mon, Nov 28, 2022 at 2:18 PM Adam Gross <[email protected]> wrote:
>>
>>> Sorry to bug you again about this. I was able to get IT to deploy this
>>> extension on top of 3.0.18 but I can't figure out the API entrypoint. I
>>> read through the GitHub merge request description, the extension repo code,
>>> and the documentation, but I still can't figure it out. I tried
>>> https://<hostname>/api/rb_reviews_api?from-user=grossag
>>> among other things. Do you know what the resource entry point is for this
>>> extension?
>>>
>>> On Wed, Nov 2, 2022 at 1:32 PM David Trowbridge <[email protected]>
>>> wrote:
>>>
>>>> Hi Adam,
>>>>
>>>> Yes, this is a new feature in 5.0. See
>>>> https://www.reviewboard.org/docs/manual/5.0/webapi/2.0/resources/root-review-list/
>>>> for docs.
>>>>
>>>> There are also root-level resources for individual comments that can be
>>>> queried similarly.
>>>>
>>>> David
>>>>
>>>> On Wed, Nov 2, 2022 at 7:11 AM Adam Gross <[email protected]> wrote:
>>>>
>>>>> Hi David, you had mentioned "We're planning on adding a new resource
>>>>> soon to query reviews across all review requests." Is this present in the
>>>>> new 5.0? If so, what is the resource name? Thanks!
>>>>>
>>>>> On Tuesday, May 10, 2022 at 1:10:40 PM UTC-4 David Trowbridge wrote:
>>>>>
>>>>>> Adam,
>>>>>>
>>>>>> This is a long-standing limitation of the current API. We're planning
>>>>>> on adding a new resource soon to query reviews across all review
>>>>>> requests.
>>>>>>
>>>>>> There is an extension that we've used internally that adds a new API
>>>>>> endpoint to do this. It's not well documented but perhaps it could serve
>>>>>> as
>>>>>> a starting point:
>>>>>> https://github.com/beanbaginc/student-sonar/tree/master/misc/rb-reviews-api
>>>>>>
>>>>>> David
>>>>>>
>>>>>> On Tue, May 10, 2022 at 6:55 AM Adam Gross <[email protected]> wrote:
>>>>>>
>>>>>>> I am working on a Python script which uses the rbtools package and
>>>>>>> collects the contributions made by a person. I started with the basic
>>>>>>> things like enumerating all code reviews posted by a user and sorting by
>>>>>>> lines of code changed.
>>>>>>>
>>>>>>> I want to add functionality to query for all reviews given by a user
>>>>>>> as part of reviewing someone else's code during a specific time period.
>>>>>>> However, I can't find any relevant web API under
>>>>>>> https://www.reviewboard.org/docs/manual/3.0/webapi/ that would fit.
>>>>>>> All of the ones that seem relevant (e.g. get_diff_comments and
>>>>>>> get_reviews)
>>>>>>> all require a review request ID instead of allowing me to do a search
>>>>>>> based
>>>>>>> on username and time period. Is there an API that would help me here?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Adam
>>>>>>>
>>>>>>> --
>>>>>>> Supercharge your Review Board with Power Pack:
>>>>>>> https://www.reviewboard.org/powerpack/
>>>>>>> Want us to host Review Board for you? Check out RBCommons:
>>>>>>> https://rbcommons.com/
>>>>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Review Board Community" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/reviewboard/d95123a1-2a6c-4174-9886-2287077dadc9n%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/reviewboard/d95123a1-2a6c-4174-9886-2287077dadc9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> --
>>>>> Supercharge your Review Board with Power Pack:
>>>>> https://www.reviewboard.org/powerpack/
>>>>> Want us to host Review Board for you? Check out RBCommons:
>>>>> https://rbcommons.com/
>>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Review Board Community" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/reviewboard/eaa61f56-a7ba-4936-8e43-69fd7c90d882n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/reviewboard/eaa61f56-a7ba-4936-8e43-69fd7c90d882n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> Supercharge your Review Board with Power Pack:
>>>> https://www.reviewboard.org/powerpack/
>>>> Want us to host Review Board for you? Check out RBCommons:
>>>> https://rbcommons.com/
>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "Review Board Community" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/d/topic/reviewboard/OBsJ7sFDsCc/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/reviewboard/CAFS3VNUqkkQN7q6yzNAeW36HnkHufG%2B7pBzz9pjiZprCEin9uQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/reviewboard/CAFS3VNUqkkQN7q6yzNAeW36HnkHufG%2B7pBzz9pjiZprCEin9uQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> Supercharge your Review Board with Power Pack:
>>> https://www.reviewboard.org/powerpack/
>>> Want us to host Review Board for you? Check out RBCommons:
>>> https://rbcommons.com/
>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Review Board Community" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/reviewboard/CAJWrGvxGW84wDKpmjirEcx2PsXLWOciUs9m332PyQ9nru1LZTA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/reviewboard/CAJWrGvxGW84wDKpmjirEcx2PsXLWOciUs9m332PyQ9nru1LZTA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> Supercharge your Review Board with Power Pack:
>> https://www.reviewboard.org/powerpack/
>> Want us to host Review Board for you? Check out RBCommons:
>> https://rbcommons.com/
>> Happy user? Let us know! https://www.reviewboard.org/users/
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Review Board Community" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/reviewboard/OBsJ7sFDsCc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/reviewboard/CAFS3VNVk%2BxDcyXT%3DFZYyWRCOxdah16d3AHz5Bbsn2Hd_4y0Xqw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/reviewboard/CAFS3VNVk%2BxDcyXT%3DFZYyWRCOxdah16d3AHz5Bbsn2Hd_4y0Xqw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
Supercharge your Review Board with Power Pack:
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons:
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups
"Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/reviewboard/CAJWrGvzGpOn-b1nRofh-1%3DMo%2BfKQTw7MS4%3DurhLpxpraffJ-NA%40mail.gmail.com.