Add Issue Status and Counts to Dashboard
Review Request #3949 — Created March 8, 2013 and discarded
This patch adds support for showing the following in the dashboard as well as "All Review Request" Pages a) The issue count in the format of <open issues> / <total issues> b) Status of a review request: + If there are no open issues and a shipit, it shows up with a green background and the shipit icon + If there are open issues and a shipit, it shows up with a red background and an exclamation sign. In addition, the review detail page shows the "ship it" emblem if there are no issues and a "ship it with issues" emblem if there are issues and a ship-it. Summary of changes: * reviewboard/reviews/datagrids.py + Added StatusColumn as a non-sortable(as there will be issues and ship it counts) column. + Added IssueCount column as a sortable column that displays the issue count in the format of <open issues> / <total issues> * reviewboard/reviews/evolutions/issue_status_count.py + Added migration scripts to add issue_{open,closed,total}_count to the reviews_reviewrequest table. * reviewboard/reviews/fixtures/test_reviewrequests.json + Added init values for issue counts in the review request fixtures. * reviewboard/reviews/managers.py + Added methods to calculate the issue open, closed and total counts for existing review requests. These will be calculated for review requests when they are accessed the first time. + Added methods to calculate the issue open, closed and total count for a new review. These will be called when a new review is published * reviewboard/reviews/models.py + Added initializer fields for issue_{open,closed,total}_count. + Since issue states can be modified by just a PUT request (and no need for a publish after that), check the old and new states when a comment is saved. Only if an issue is opened and the states change, increment/decrement the issue counts. + Calculate the issue counts when a review is published. * reviewboard/reviews/tests.py + Added couple of tests where all types of comments (screenshot, attachment, diff) are added, issues created against them and closed. The issue counts are verified at every stage. * reviewboard/templates/reviews/review_detail.html + Modified the review_detail template to show "ship it" or "ship it with issues" depending on whether there are open issues with a Ship It. * reviewboard/webapi/resources.py + Added issue_open_count and issue_total_count when GET-ting a ReviewRequestResource + Provide filtering capabilities so open-issues can be queried when getting a list of review-requests * reviewboard/webapi/tests.py + Modified couple of tests related to creating issues to include issue counts and verified whether the counts are appearing properly. Note: The djblets changes associated with this are in review request 3948
Manual testing as well as running the test suite with additional tests. Also tested webapi resources manually and through the webapi tests.
Description | From | Last Updated |
---|---|---|
Others get this wrong, but this should follow the proper docstring model: """One-line summary. Multi-line description. """ |
chipx86 | |
Other columns get this wrong, but this should be: super(StatusColumn, self).__init__...) Same with IssueCountColumn. |
chipx86 | |
This can be flattened by having this check == 0 and return ''. Fewer nesting if statements is good. |
chipx86 | |
The strings are aligned weirdly. |
chipx86 | |
Col: 25 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 25 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 30 E127 continuation line over-indented for visual indent |
reviewbot | |
Same comment about the docstring. |
chipx86 | |
Same comment about alignment. |
chipx86 | |
Col: 21 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 16 E221 multiple spaces before operator |
reviewbot | |
Col: 11 E221 multiple spaces before operator |
reviewbot | |
Each of these functions should have a docstring. The "review_request" shouldn't be necessary. I think these would be best added … |
chipx86 | |
Blank line after imports. |
chipx86 | |
I think I'd prefer to just use return statements instead of setting a variable and returning in both cases. Shortens … |
chipx86 | |
Blank line before this. |
chipx86 | |
Blank line before this. |
chipx86 | |
Blank line before this. |
chipx86 | |
This sounds like it's the count of review requests. Maybe _get_comment_count. |
chipx86 | |
This is really inefficient. First off, these can be simplified with: for review in review_request.reviews.filter(public=True) for comment in review.get_all_comments(issue_status__in=issue_status) That … |
chipx86 | |
to prevent counting issue_status=O+ opened_issue=0 bug #2984 https://code.google.com/p/reviewboard/issues/detail?id=2984 I'd propose to prefix test by "comment.issue_opened and" => if comment.issue_opened and … |
DE delyn | |
Same comments apply to all these. |
chipx86 | |
to prevent counting issue_status=O+ opened_issue=0 bug #2984 https://code.google.com/p/reviewboard/issues/detail?id=2984 I'd propose to prefix test by "comment.issue_opened and" => if comment.issue_opened and … |
DE delyn | |
what can be done to prevent updating reviewrequest last_updated during database evolution and init of new fields? Indeed, all existing … |
DE delyn | |
Indentation would be best as: initializer=lambda r: (r.pk and r.get_open_issue_count() or 0) |
chipx86 | |
Blank line before this. |
chipx86 | |
Weird indentation. Should use parens for multi-line conditionals. Also, blank line before the first if statement here. |
chipx86 | |
This is all getting quite repetitive. How about: comment_fields = ['comments', 'screenshot_comments', 'file_attachment_comments'] for comment_field in comment_fields: comments = getattr(self, … |
chipx86 | |
Each type of operation should be tested separately, so that we can know exactly what is failing when. |
chipx86 | |
Col: 80 E501 line too long (97 > 79 characters) |
reviewbot | |
This is too long. Can you do: {% if entry.review.ship_it %} {% trans ... %} {% if issue_open_count %} ... … |
chipx86 | |
Might as well add closed counts too. |
chipx86 | |
Might as well do this for closed and total counts too. |
chipx86 |
-
Nitpicks: - Would be nice if issues had a subtle gradient background like 'ship it'. - Would be nice if the status bubble didn't have so much extra empty space to the right. (For that matter, should the number be right-justified?) ...but I'd rather have it land without those tweaks than not at all :-). Thanks for working on this!
-
as discussed on issue #2723 http://code.google.com/p/reviewboard/issues/detail?id=2723#c14
-
to prevent counting issue_status=O+ opened_issue=0 bug #2984 https://code.google.com/p/reviewboard/issues/detail?id=2984 I'd propose to prefix test by "comment.issue_opened and" => if comment.issue_opened and comment.issue_status in issue_status)
-
to prevent counting issue_status=O+ opened_issue=0 bug #2984 https://code.google.com/p/reviewboard/issues/detail?id=2984 I'd propose to prefix test by "comment.issue_opened and" => if comment.issue_opened and comment.issue_status in issue_status)
-
Hey, Thanks for the change. Sorry this has totally fallen off my radar. There's some things I'd like to see changed before this goes in.
-
Others get this wrong, but this should follow the proper docstring model: """One-line summary. Multi-line description. """
-
Other columns get this wrong, but this should be: super(StatusColumn, self).__init__...) Same with IssueCountColumn.
-
-
-
-
-
Each of these functions should have a docstring. The "review_request" shouldn't be necessary. I think these would be best added to the ReviewRequest object. Then these would just operate on the ReviewRequest they're called on. Also resolves the inline import stuff.
-
-
I think I'd prefer to just use return statements instead of setting a variable and returning in both cases. Shortens the code.
-
-
-
-
-
This is really inefficient. First off, these can be simplified with: for review in review_request.reviews.filter(public=True) for comment in review.get_all_comments(issue_status__in=issue_status) That reduces what's called. Still, it causes a large number of queries. That can be further reduced with: review_request.reviews.filter( Q(public=True) & (Q(comments__issue_status__in=issue_status) (Q(screenshot_comments__issue_status__in=issue_status) (Q(file_attachment_comments__issue_status__in=issue_status))) Then you can avoid sum(), and just use .count().
-
-
-
-
Weird indentation. Should use parens for multi-line conditionals. Also, blank line before the first if statement here.
-
This is all getting quite repetitive. How about: comment_fields = ['comments', 'screenshot_comments', 'file_attachment_comments'] for comment_field in comment_fields: comments = getattr(self, comment_field) for comment in comments: ...
-
Each type of operation should be tested separately, so that we can know exactly what is failing when.
-
This is too long. Can you do: {% if entry.review.ship_it %} <div class="..."> {% trans ... %} {% if issue_open_count %} ... {% endif %} </div> {% endif %}
-
-
-
Hey,
Just letting you know that I've put together a set of changes that accomplishes this same goal, with some small differences in design and implementation. Much of the code in Review Board has changed since this change, so there wasn't a ton to reuse, but it was heavily inspired by the change, so thanks!
You'll see this in RB 2.0 beta 3.