Add a feature to automatically suggest reviewers for a given review request
Review Request #5740 — Created April 25, 2014 and submitted
This change is, for the most part, the same as Natasha's change at /r/5029. I had to port it over to the new fields code, and make a handful of other small changes to get it to work.
My plan is to push this to a branch off master, where we can play with it and do some performance testing.
Description | From | Last Updated |
---|---|---|
""" on the next line. |
chipx86 | |
We should be using format_html. Would also be nice to use dictionary args for formatting. |
chipx86 | |
Should use format_html here too. |
chipx86 | |
Should use single quotes. |
chipx86 | |
Swap these. |
chipx86 | |
Blank line after this. |
chipx86 | |
Blank line between these. |
chipx86 | |
How about post_field_html instead of extra_html? Would be nice to be explicit there, in case we decide to allow for … |
chipx86 | |
If we don't mind a little extra '/' stripping, this can be: diffed_files = [ fd.source_file.lstrip('/') for fd in diffset.files.all() … |
chipx86 | |
Alignment looks weird. |
chipx86 | |
Let's swap these conditions. rr_id != self.pk is a faster check. |
chipx86 | |
This can be: user, user_timestamp, related_review_request = all_reviews[rev] |
chipx86 | |
I don't know if it's faster to use six.iteritems here, but since this will be the equivalent of iteritems on … |
chipx86 | |
This is formatted awkwardly. How about: sorted_users = [ user for user, weight in ... ] |
chipx86 | |
Can we pull out .suggest-user once, instead of re-querying every time? |
chipx86 | |
With the exception of selector above, all of these are in alphabetical order. Can we move these (and selector) to … |
chipx86 | |
Should just use a pre-fetched element. |
chipx86 | |
This looks to be doing too much. If we kept this logic, then this could just be: this._$suggestedPeople .empty() .append($allPeople); … |
chipx86 | |
We fetch all the diffsets in review_detail. It'd be nice to make use of those to grab the latest, if … |
chipx86 | |
Col: 80 E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
This terrifies me still. It's a large join. We should do some testing against large MySQL databases before this goes … |
chipx86 | |
Col: 26 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
list comprehension redefines 'user' from line 195 |
reviewbot | |
list comprehension redefines 'weight' from line 206 |
reviewbot |
- Commit:
-
6a38117a66310509d56a5d874d4cfebd575417eb617877d9f3e05f0f20faf59242e0f04a503f3a58
- Diff:
-
Revision 2 (+226 -5)
-
-
If we don't mind a little extra '/' stripping, this can be:
diffed_files = [ fd.source_file.lstrip('/') for fd in diffset.files.all() ]
-
-
-
-
-
I don't know if it's faster to use
six.iteritems
here, but since this will be the equivalent of iteritems on Python 3.x, we might as well use it for 2.x for consistency. -
-
-
With the exception of
selector
above, all of these are in alphabetical order. Can we move these (andselector
) to be consistent in that way? -
-
This looks to be doing too much. If we kept this logic, then this could just be:
this._$suggestedPeople .empty() .append($allPeople);
However, I'm not really sure why we need to do all this work. I wasn't sure why we were, but I suspect it's because we insert those ',' characters. If so, we're just doing way too much work here.
What I'd suggest is not doing any of this, and instead just list the visible users as standard elements. Then, in CSS, we can do something like:
.suggest-user:after { content: ", " } .suggest-user:last-child:after { content: "" }
- Commit:
-
617877d9f3e05f0f20faf59242e0f04a503f3a58ee498ffcf2c5f8ac874d2c236a0eadfbc6db6058
- Diff:
-
Revision 3 (+207 -5)
-
Tool: Pyflakes Processed Files: reviewboard/reviews/builtin_fields.py reviewboard/reviews/models/base_review_request_details.py reviewboard/reviews/fields.py Ignored Files: reviewboard/templates/reviews/review_request_box.html reviewboard/static/rb/css/pages/reviews.less reviewboard/static/rb/js/views/reviewRequestEditorView.js Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/builtin_fields.py reviewboard/reviews/models/base_review_request_details.py reviewboard/reviews/fields.py Ignored Files: reviewboard/templates/reviews/review_request_box.html reviewboard/static/rb/css/pages/reviews.less reviewboard/static/rb/js/views/reviewRequestEditorView.js
-
-
-
-
-
-
-
We fetch all the diffsets in review_detail. It'd be nice to make use of those to grab the latest, if available, to reduce a query.
I'm very concerned about the impact this feature will have to load times, so any query reduction we can do is very important.
-
This terrifies me still. It's a large join. We should do some testing against large MySQL databases before this goes in. I'd like to see whether it's faster to do a large join, or to split it into a couple different queries.
One thought on optimization:
We're going to fetch a lot of user data, and a lot of it may be the same data. Instead of grabbing 'user', let's just grab the ID, and then after we dedup later, we can fetch the data we need from those user IDs. Same for the
reviews__user
.