Add general comments ability to Review Bot
Review Request #10335 — Created Nov. 27, 2018 and submitted
Continuation of work from here:
https://reviews.reviewboard.org/r/10095/Similar to how a tool can post diff comments on a file, they
can now also post general comments on the review. This also
paves the way for tools to post file and screenshot comments
(but does not add this functionality).
Was able to post an automated review with/without general
comments, opening issues on some comments and not on others.
Also posted an automated review with 35 general comments and
1 diff comment -> only 30 got posted, all of which were the
general comments.
Likewise posted an automated review with 15 general comments
and 17 diff comments -> only 30 (total) got posted, 15 general
and 15 diff.
Additionally, tried using an updated Review Board server with
a worker without the changes -> No errors, everything works
as expected.
Description | From | Last Updated |
---|---|---|
Description and testing done should probably be wrapped at 72 characters. |
shoven | |
This does len(diff_comments) queries when we can do this in a single query: filediffs_pks = { comment['filediff_id'] for comment in … |
brennie | |
The value should be a list of errors. |
brennie | |
This really should use bulk_create to do 2 queries instead of len(diff_comments) + len(general_comments) queries, e.g. for comment_type, comments in … |
brennie | |
The value should be a list of errors (though a single error with the missing keys is fine). |
brennie | |
F401 'reviewboard.reviews.models.Comment' imported but unused |
reviewbot | |
F401 'reviewboard.reviews.models.GeneralComment' imported but unused |
reviewbot | |
F821 undefined name 'rdb' |
reviewbot | |
Since the data variable you are declaring is only being used once you could do this all inline. |
shoven | |
Mind updating this docstring to the modern format? |
david | |
Can we call this filediff_pks? |
david | |
Add a blank line here. |
david | |
Add a blank line here. |
david | |
This needs a "Returns" section |
david | |
E501 line too long (80 > 79 characters) |
reviewbot | |
F841 local variable 'filediffs' is assigned to but never used |
reviewbot | |
This is intented too far (should line up with reviewboard on the line above) |
david | |
This isn't quite right. This method returns a 2-tuple containing an HTTP return code and the API payload. |
david | |
"JSON" isn't a python type. This method returns a list of the decoded and normalized comments. |
david |
-
-
This does
len(diff_comments)
queries when we can do this in a single query:filediffs_pks = { comment['filediff_id'] for comment in diff_comments } filediffs = { filediff.pk: filediff for filediff in FileDiff.objects.filter( pk__in=filediff_pks, diffset__history__review_request=review_request ) } for comment in diff_comments: filediff_id = comment.pop('filediff_id') try: comment['filediff'] = filediffs[filediff_id] except KeyError: return INVALID_FORM_DATA, { 'fields': { 'diff_comments': [ 'Invalid filediff ID: %s' % filediff_id, ], }, }
This also means do you don't need the
except ObjectDoesNotExist
branch (since that case is handled in theKeyError
branch). -
-
This really should use bulk_create to do 2 queries instead of
len(diff_comments) + len(general_comments)
queries, e.g.for comment_type, comments in ((Comment, diff_comments), (GeneralComment, general_comments)): models = [ comment_type(review=new_review, **comment) for comment in comments ] comment_type.bulk_create(models)
-
-
- Commit:
-
a006cb12855fbaad092a4e7d1865766f9ad7ef204fd04a4e657aaf294eec2e77cb135afb936cd7be
Checks run (2 succeeded)
- Description:
-
~ Continuation of work from here: https://reviews.reviewboard.org/r/10095/
~ Continuation of work from here:
+ https://reviews.reviewboard.org/r/10095/ ~ Similar to how a tool can post diff comments on a file, they can now also post general comments on the review.
~ This also paves the way for tools to post file and screenshot comments (but does not add this functionality) ~ Similar to how a tool can post diff comments on a file, they
~ can now also post general comments on the review. This also + paves the way for tools to post file and screenshot comments + (but does not add this functionality). - Testing Done:
-
~ Was able to post an automated review with/without general comments, opening issues on some comments and not on others.
~ Also posted an automated review with 35 general comments and 1 diff comment -> only 30 got posted, all of which were the general comments. ~ Likewise posted an automated review with 15 general comments and 17 diff comments -> only 30 (total) got posted, 15 general and 15 diff. ~ Additionally, tried using an updated Review Board server with a worker without the changes -> No errors, everything works as expected. ~ Was able to post an automated review with/without general
~ comments, opening issues on some comments and not on others. ~ Also posted an automated review with 35 general comments and ~ 1 diff comment -> only 30 got posted, all of which were the + general comments. + Likewise posted an automated review with 15 general comments + and 17 diff comments -> only 30 (total) got posted, 15 general + and 15 diff. + Additionally, tried using an updated Review Board server with + a worker without the changes -> No errors, everything works + as expected. - Commit:
-
4fd04a4e657aaf294eec2e77cb135afb936cd7bee8c673be8c40b39f61e260fcd3f4bd8c1e08d2b7
Checks run (2 succeeded)
- Commit:
-
c34b79ca3200356ca69c38acb77bbe0adf443f1ed27a1b1d3cfd2c1643eccdcec915182c62739169