- Status:
- Discarded
Adding smarter update notifications
Review Request #8519 — Created Nov. 3, 2016 and discarded
When viewing a review request, Review Board periodically checks
to see if there have been any updates to the review request.
Currently we only receive updates regarding the type of change
and who it was made by. The goal of this project is to improve
on the detail provided.
Added unit tests for backend code - all pass.
Manually verified API response locally.
Description | From | Last Updated |
---|---|---|
Col: 80 E501 line too long (84 > 79 characters) |
reviewbot | |
undefined name 'DiffSet' |
reviewbot | |
Col: 80 E501 line too long (97 > 79 characters) |
reviewbot | |
The way you are currently doing this is going to build 7 lists. Each call to list() will create one … |
brennie | |
Col: 80 E501 line too long (97 > 79 characters) |
reviewbot | |
This can throw if someone does ?timestamp=0 or some other invalid format. |
brennie | |
utc_timestamp will always be truthy. If we fail to parse the timestamp, we will get an exception. |
brennie | |
So there are 4 comment types (comments, general, file attachment, and screenshot). That means for every review we will be … |
brennie | |
We will probably want to get reviews and replies in two separate lists (may want to confer with christian on … |
brennie | |
This isn't being used anymore. |
brennie | |
Timestamps on a review are all set to the same value when published. This whole function wouldn't be doing anything … |
chipx86 | |
Make sure to follow the conventions for docstrings, specifically "Args" and "Returns". https://www.reviewboard.org/docs/codebase/dev/docs/writing-codebase-docs/ |
chipx86 | |
I don't think we should be adding new methods that just produce different variations of a query here. This query … |
chipx86 | |
We should always say "review request" instead of "request" (which tends to be the term for HTTP Request). |
chipx86 | |
This should not return DiffSets associated with review request drafts, i.e. review_request_draft=None. |
brennie | |
Same here as above. |
chipx86 | |
This should make sure that the reviews aren't drafts, i.e., public=True. |
brennie | |
timestamp doesn't need to be in quotes. Also can you change this to: data: { timestamp: this._lastUpdateTimestamp, }, |
brennie | |
Make sure this doesn't stay :) |
brennie | |
Instead of importing pytz, you should do from django.utils.timezone import utc. |
brennie | |
Single import statement, one name per line. |
brennie | |
This should be the WebAPI resource and not the model, i.e. [reviewboard.webapi.resources.diff.DiffResource] |
brennie | |
This shouldn't be a string. It should be a reference to the resource model. Same below. |
chipx86 | |
This should be the WebAPI resource and not the model, i.e. [reviewboard.webapi.resources.review.ReviewResource] |
brennie | |
This should be the WebAPI resource and not the model, i.e. [reviewboard.webapi.resources.base_comment.BaseCommentResource] (I think?) You will want to build the … |
brennie | |
"out-of-date" |
chipx86 | |
No blank line here. |
chipx86 | |
This comment isn't really clear. I think this is meant to be an example of the format, but if so, … |
chipx86 | |
Since you never use timestamp again, just reassign to timestamp. |
brennie | |
After you remove the pytz import you can convert to a aware time with (timezone.get_default_timezone() .localize(datetime .strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ'))) |
CO Connor-Y | |
Comments should be proper sentences, periods and all. |
chipx86 | |
Just call this reviews. |
brennie | |
Blank line between code and new comments. |
chipx86 | |
This isn't too gross :). However, instead of iterating over this twice, we can iterate once: new_reviews = [] new_replies … |
brennie | |
Col: 80 E501 line too long (100 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (101 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
This isn't too helpful to the caller. There should be suitable error information. However, we're also not actually working with … |
chipx86 | |
Docstring etc. I would rename new_reviews to just reviews. |
brennie | |
Can you make this a constant on the class? |
brennie | |
This needs to be review_id__in or review__pk__in. Also, one per line. |
brennie | |
from django.utils import six |
brennie | |
This file is missing a: from __future__ import unicode_literals Which must be at the top. |
chipx86 | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Missing a docstring. |
chipx86 | |
Blank line between these. |
chipx86 | |
Blank line between these. |
chipx86 | |
'INVALID_FORM_DATA' imported but unused |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 9 E303 too many blank lines (2) |
reviewbot | |
Col: 13 E116 unexpected indentation (comment) |
reviewbot | |
Col: 13 E265 block comment should start with '# ' |
reviewbot | |
Col: 13 E116 unexpected indentation (comment) |
reviewbot | |
Col: 13 E116 unexpected indentation (comment) |
reviewbot | |
Col: 63 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
undefined name 'DOES_NOT_EXIST' |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
These can probably all be condensed into one test. |
brennie | |
undefined name 'DOES_NOT_EXIST' |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
undefined name 'review_request' |
reviewbot | |
undefined name 'DOES_NOT_EXIST' |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
undefined name 'review' |
reviewbot | |
undefined name 'review' |
reviewbot | |
Col: 47 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
undefined name 'DOES_NOT_EXIST' |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 47 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 80 E501 line too long (88 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 47 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 80 E501 line too long (88 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 47 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
'datetime' imported but unused |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 37 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 42 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 27 E201 whitespace after '{' |
reviewbot | |
Col: 32 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 33 E201 whitespace after '{' |
reviewbot | |
Col: 27 E201 whitespace after '{' |
reviewbot | |
Col: 32 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 33 E201 whitespace after '{' |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
'datetime' imported but unused |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 37 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 42 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 27 E201 whitespace after '{' |
reviewbot | |
Col: 32 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 33 E201 whitespace after '{' |
reviewbot | |
Col: 27 E201 whitespace after '{' |
reviewbot | |
Col: 32 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 33 E201 whitespace after '{' |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Undo this. |
brennie | |
This won't (or shouldn't, anyway) result with the timestamp saved to the review request in the DB. Instead of setting … |
brennie | |
This can eventually lead to fun to debug circular reference issues. Instead, when you want to refer to ReviewResource you … |
brennie | |
This should actually be: ['reviewboard.webapi.resources.diff.DiffResource'] |
brennie | |
Same goes for here with the appropriate resource |
brennie | |
Same goes for here with the appropriate resource |
brennie | |
Same goes for here with the appropriate resource |
brennie | |
Same goes for here with the appropriate resource |
brennie | |
Constant names should be ALL_CAPS. Also, can you format this as: COMMENT_TYPES = ( Comment, # ... ) |
brennie | |
Don't use exceptions like this for flow control. Instead: if not timestamp: # old behaviour return ... try: timestamp = … |
brennie | |
This documentation needs to go into the docs for the timestamp field. |
brennie | |
No blank line here. |
brennie | |
When the timestamp is provided and invalid, we want to give an INVALID_FORM_DATA response. |
brennie | |
missing docstring. |
brennie | |
Needs file docstring. |
brennie | |
Blank line between these. |
brennie | |
Blank line between these. |
brennie | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
Col: 17 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Docstring. |
brennie | |
Let's leave the comment, please. |
david | |
Even though the line would go over 80 columns, let's keep this in one piece. |
david | |
Col: 21 E128 continuation line under-indented for visual indent |
reviewbot | |
This is only used once in an internal method, so let's just have it inline there. |
david | |
Col: 5 E124 closing bracket does not match visual indentation |
reviewbot | |
We only use this in the one place, so let's avoid assigning the extra variable (or constructing the list): for … |
david | |
We shouldn't need to convert to list here. |
david | |
Keep this on one line, even though it's long. Should also be list of reviewboard.webapi.resource.review.ReviewResource |
david | |
Same here re list of .... This also doesn't need the parens. |
david | |
It looks like some of your other change has snuck in here. Do you have one branch dependent on the … |
david | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 9 E124 closing bracket does not match visual indentation |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 9 E124 closing bracket does not match visual indentation |
reviewbot | |
This line should be empty |
FI finaiized | |
Blank line in between here. |
david | |
Should be formatted as: Returns: unicode: The resulting absolute URL to teh item resource. |
david | |
Blank line between these. |
brennie | |
This should be the resource, e.g. ['reviewboard.webapi.resources.diff.DiffResource']. |
brennie | |
This should be the resource, e.g. ['reviewboard.webapi.resources.review.ReviewResource']. |
brennie | |
This should be the resource, e.g. ['reviewboard.webapi.resources.review_reply.ReviewReplyResource']. |
brennie | |
This should be the resource, e.g. ['reviewboard.webapi.resources.base_comment.BaseCommentResource']. |
brennie | |
This should be the resource, e.g. ['reviewboard.webapi.resources.change.ChangeResource']. |
brennie | |
You can refactor this to remove code duplication. try: timestamp = datetime.strptime(timestamp, ...).replace(tzinfo=utc) except ValueError: timestamp = None if timestamp … |
brennie | |
Col: 46 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 46 E127 continuation line over-indented for visual indent |
reviewbot | |
These keys are common between all responses, so you can further refactor the code to do: response_keys = { 'timestamp': … |
brennie | |
local variable 'comment_types' is assigned to but never used |
reviewbot | |
Make this a class level constant, e.g., self.COMMENT_TYPES. |
brennie | |
Col: 9 E124 closing bracket does not match visual indentation |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 9 E124 closing bracket does not match visual indentation |
reviewbot | |
Col: 26 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 9 E124 closing bracket does not match visual indentation |
reviewbot |
- Status:
- Re-opened
- Summary:
-
Integrating Extension mixin in to RB root resource[WIP] Adding smarter update notifications
- Description:
-
- [WIP] Adding smarter update notifications
- When viewing a review request, ReviewBoard periodically checks
to see if there have been any updates to the review request. Currently we only receive updates regarding the type of change and who it was made by. The goal of this project is to improve on the detail provided. - Commit:
-
1e4c2f3758debd08feecedd1f0817102674d5282
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
- Description:
-
~ When viewing a review request, ReviewBoard periodically checks
~ When viewing a review request, Review Board periodically checks
to see if there have been any updates to the review request. Currently we only receive updates regarding the type of change and who it was made by. The goal of this project is to improve on the detail provided.
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/webapi/resources/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/webapi/resources/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
The way you are currently doing this is going to build 7 lists. Each call to
list()
will create one (so thats 4) and each addition will create a new intermediate list (and there are 3 of those). that is quite expensive in terms of memory allocation. Ideally we want to use one list and uselist.extend
:comment_types = ( self.comments, self.screenshot_comments, self.file_attachment_comments, self.general_comments, ) comments = [] for comment_type in comment_types: comments.extend(comment_type.filter(timestamp__gt=timestamp))
-
-
-
So there are 4 comment types (comments, general, file attachment, and screenshot). That means for every review we will be doing four queries, so we're going to be doing
4 * r
queries. We really don't want to be doing this.If we had a large review request, with say 100 reviews, someone could query the api with
?timestamp=1970-01-01T00:00:00Z
and get every review and we'd have to do 400 database queries. This can lead to denial of service attacks.We really want to do the minimum number of queries here, which will be four. Instead of going through each individual
review
, you'll have to query through each comment class, e.g.:review_pks = [review.pk for review in new_reviews] new_comments = [] comment_types = (Comment, FileAttachmentComment, GeneralComment, ScreenshotComment) for comment_cls in comment_types: new_comments.extend(comment_cls.objects.filter( review_id__in=review_pks, timestamp__gt=timestamp))
If we need to parse out comments to their respective reviews afterwards, we can post-process the dataset.
-
Replies are not comment updates. Replies are actually a
Review
object withbase_reply_to
having a non-null value. -
We will probably want to get reviews and replies in two separate lists (may want to confer with christian on that). However, you can do one query for each type of review + reply and then filter them out in python land.
- Change Summary:
-
Addressing review comments. Broke up reviews and replies from being returned in the same list. Started developing unit tests in line with other API classes.
- Commit:
-
9d9bd3a3fb4d52322c6d3b958be9b8e39dcc4532c1fd6e792305a399623769e098705f917977de35
- Diff:
-
Revision 6 (+184 -6)
-
Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/reviews/models/review.py reviewboard/reviews/models/review_request.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
This should not return
DiffSet
s associated with review request drafts, i.e.review_request_draft=None
. -
-
timestamp
doesn't need to be in quotes. Also can you change this to:data: { timestamp: this._lastUpdateTimestamp, },
-
-
-
-
This should be the WebAPI resource and not the model, i.e.
[reviewboard.webapi.resources.diff.DiffResource]
-
This should be the WebAPI resource and not the model, i.e.
[reviewboard.webapi.resources.review.ReviewResource]
-
This should be the WebAPI resource and not the model, i.e.
[reviewboard.webapi.resources.base_comment.BaseCommentResource]
(I think?) You will want to build the docs and see if this one works. If so, theBaseCommentResource
will likely want to include links to all resource types in its class docstring.The docs you want to check are the
webapi/
docs, not the class documentation for the resource. -
-
-
This isn't too gross :). However, instead of iterating over this twice, we can iterate once:
new_reviews = [] new_replies = [] for review in reviews: if review.base_reply_to: new_replies.append(review) else: new_reviews.append(review)
-
-
-
-
-
-
The overall results of the API look good. There's some additions in this change that don't need to be there, and some consistency things to work on. Good work so far, though!
-
Timestamps on a review are all set to the same value when published. This whole function wouldn't be doing anything other than
get_all_comments
. -
Make sure to follow the conventions for docstrings, specifically "Args" and "Returns".
https://www.reviewboard.org/docs/codebase/dev/docs/writing-codebase-docs/
-
I don't think we should be adding new methods that just produce different variations of a query here. This query is simple enough that it can and should be used by the caller.
The reason is that we don't want to establish precedent. We probably have a hundred or more distinct queries involving attributes of a
ReviewRequest
throughout the codebase, and if we had a method for each one in this class, the class would massively balloon up.So instead, let's get rid of this and just do this query directly where it needs to be called.
-
We should always say "review request" instead of "request" (which tends to be the term for HTTP Request).
-
-
-
-
-
This comment isn't really clear. I think this is meant to be an example of the format, but if so, the comment should state that. However, saying that it's a ISO8601 timestamp is sufficient.
-
-
-
This isn't too helpful to the caller. There should be suitable error information.
However, we're also not actually working with form data, so the error is incorrect.
There's really a lot of code in this
try/except
. What part is expected to raise theValueError
? We should limit the code around that, and perhaps not error out but instead fall back to old behavior (not showing the new fields). -
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/test_review_request_last_update.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/test_review_request_last_update.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/test_review_request_last_update.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/test_review_request_last_update.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
- Change Summary:
-
Trying to get the default get tests running on
test_review_request_last_update.py
- running in to some issues. - Testing Done:
-
+ Added unit tests.
- Commit:
-
42dc1cc02999eb438d15adaa6ba42b7e836e2d3e3a4694b1a3edc24e476b0b168b952d806b8cb436
- Change Summary:
-
Built in get tests running.
- Commit:
-
3a4694b1a3edc24e476b0b168b952d806b8cb43622f974e40f4846c7f48bfaca6868146ee815ae81
-
Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
- Commit:
-
2f92034fe3f0ce6b40d7b8c50a0b805cf693041ac00252b533afab2dc267068d2e12a189e2b072fd
- Diff:
-
Revision 14 (+343 -8)
-
Tool: Pyflakes Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
-
-
-
- Commit:
-
c00252b533afab2dc267068d2e12a189e2b072fdefe772e8044a9ee596543afed738bbf42fbfd7a3
- Diff:
-
Revision 15 (+353 -8)
-
Tool: Pyflakes Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Resolving unit test comparator function.
- Commit:
-
efe772e8044a9ee596543afed738bbf42fbfd7a39339cd39c020ad595911459603a96d2e90068b12
- Diff:
-
Revision 16 (+359 -8)
-
Tool: Pyflakes Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
This won't (or shouldn't, anyway) result with the timestamp saved to the review request in the DB. Instead of setting review.timestamp, and calling
save()
(which is whatpublish()
), you will have to do:Review.objects.filter(pk=review.pk).update(timestamp=timestamp)
-
This can eventually lead to fun to debug circular reference issues. Instead, when you want to refer to
ReviewResource
you can do:resources.review
. -
-
-
-
-
-
-
Don't use exceptions like this for flow control.
Instead:
if not timestamp: # old behaviour return ... try: timestamp = datetime.strptime(...) except ValueError: return INVALID_FORM_DATA, { fields: { 'timestamp': [ 'error here', ], }, } # continue calculating advanced response.
-
-
-
-
-
-
-
-
- Commit:
-
9339cd39c020ad595911459603a96d2e90068b1230f51d395ec06d1bf00332c629dd44617a9637ff
- Diff:
-
Revision 17 (+414 -9)
-
Tool: Pyflakes Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/root.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/root.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
We only use this in the one place, so let's avoid assigning the extra variable (or constructing the list):
for review in Review.objects.filter( review_request=review_request, timestamp__gt=timestamp, public=True): if review.base_reply_to: ...
-
-
Keep this on one line, even though it's long.
Should also be
list of reviewboard.webapi.resource.review.ReviewResource
-
-
It looks like some of your other change has snuck in here. Do you have one branch dependent on the other?
-
-
- Branch:
-
masterrelease-3.0.x
- Commit:
-
30f51d395ec06d1bf00332c629dd44617a9637ff8fe69efe5d1a461b374bee2f0cb4b61439896ac7
- Diff:
-
Revision 18 (+414 -7)
-
Tool: Pyflakes Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js Tool: PEP8 Style Checker Processed Files: reviewboard/testing/testcase.py reviewboard/webapi/tests/test_review_request_last_update.py reviewboard/webapi/resources/review_request_last_update.py reviewboard/webapi/tests/urls.py reviewboard/webapi/tests/mimetypes.py Ignored Files: reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
This should be the resource, e.g.
['reviewboard.webapi.resources.review_reply.ReviewReplyResource']
. -
This should be the resource, e.g.
['reviewboard.webapi.resources.base_comment.BaseCommentResource']
. -
-
You can refactor this to remove code duplication.
try: timestamp = datetime.strptime(timestamp, ...).replace(tzinfo=utc) except ValueError: timestamp = None if timestamp is None: # Old behaviour. return 200, { ... }, { 'ETag': etag, } # New behaviour ...
-
These keys are common between all responses, so you can further refactor the code to do:
response_keys = { 'timestamp': server_timestamp, 'user': user, 'summary': summary, 'type': update_type, } # try/except to check for timestamp ... if timestamp is None: # Calculate new_diffsets, etc. response_keys.update({ 'diffset_update': new_diffsets, 'review_updates': new_reviews, 'reply_updates': new_replies, 'comment_updates': new_comments, 'field_updates': field_updates, }) return 200, { self.item_result_key: response_keys, }, { 'ETag': etag, }
This eliminates the multiple returns and makes it easier to follow.
Additionally, can you ensure the keys are listed in alphabetical order when being inserted?
-