Add a "Last Updated By" column to the dashboard.

Review Request #12018 — Created Jan. 28, 2022 and updated

Information

Review Board
master

Reviewers

These changes add a new column to the review request dashboard called "Last Updated By" which displays the user that made the last update to each review request. Similar to the existing "Last Updated" column, which shows the time that the last update was made, this column is updated whenever a review request is created, edited, receives a review, is closed, or reopened.

Changes

"Last Updated By" column

  • Added a "Last Updated By" column
  • Added information about the new column to manual
  • Added tests for the new column

ReviewRequest last activity info functions

  • ReviewRequest.get_last_activity_info() also returns the user that last updated the review request
  • Review requests cache their last activity info (last updated object, changedesc, and user) in ReviewRequest.extra_data
  • Added ReviewRequest.set_last_activity_info(timestamp, updated_object, changedesc, user)
  • Modified existing uses of ReviewRequest.get_last_activity_info() to take advantage of the user field
  • Added and modified existing tests of ReviewRequest.get_last_activity_info()

Other

  • Made the WebAPI ReviewRequestLastUpdateResource return the correct user now that ReviewRequest.get_last_activity_info() includes it
  • Added tests for the column itself as well as the new last activity-related functions.
  • Ran all backend tests and observed that all passed.
  • Performed manual testing of the functionality of the column by creating, editing, reviewing, closing, and reopening review requests and observing how the column changes.
Summary ID
Add a "Last Updated By" column to the dashboard
2886dc701a7582abb5ab763c2d9c1fe7ba1d542b
First try at optimization of get_last_activity_info
347e5aa8a529bc8b6aaea55d331475446f4d3b63
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
bba4df2b0cd2f382bb4eb2d88dd5a20cb92f9b22
Fix import error in review_request.py
9eead2a3139e9cec4e82a13c376d33fc558582f7
Fix incorrect argument order
19d8bb48e3e7a2ae0536196102556e00918acf96
None handling for changedesc
f568b695db1d1f7372b8dc53e5eee94aca606785
Fetch users in Last Updated By column in one query
3a44a50bec97041c994a6b7b342998c9c6f942f2
Add LastUpdatedByColumnTests based on UsernameColumnTests
410e1b643422b85781aa59d6a59f005b1c898c71
Fix ReviewRequest.set_last_activity_info() failing when user is None
b076ce9a7ead039ffb03c6e1f27b6775a31c712d
Add info on Last Updated By column to dashboard documentation
9dfd7179ef9462d8463a230e0769f7fa3b4e7dcb
Fix issues with review request closing updating last activity info
- Make closing a review request use the same timestamp for last_updated and the ChangeDescription - Fix test_get_last_activity_info_close
caf3389617783d8d0d40393f750381fba7424f8f
Handle user being None in ReviewRequest.get_last_activity_user_id()
d1b2f75efb0be1df4e8ba081ed3b5616be574067
Make ReviewRequest.publish() set updated_object to diffset if it exists
c3bd1a09f5a1ac7359cf7f89628067d86cd74a70
Update last activity info when review request is reopened
bb22a4b741f7ff917b1c4b1dce19afca681c5e95
Fix last_updated being set incorrectly after publishing ReviewRequest
2d5599330ffb81e6e5c02fc28c17c91ff6e88487
Send the correct user in ReviewRequestLastUpdateResource
cdb0cfc28c3f678a77d1f779daa05da483a6915c
Fix ReviewRequest.reopen() setting last activity info after no status change
3120d9fe3af41f0467404c49716457599d42ac3b
Make changes to address feedback
e606ba6247e22f74d4d40b1e28cc8d34de4549e8
Description From Last Updated

E501 line too long (94 > 79 characters)

reviewbotreviewbot

F401 'reviewboard.diffviewer.models.diffset.DiffSet' imported but unused

reviewbotreviewbot

F401 'reviewboard.reviews.models.review.Review' imported but unused

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E501 line too long (94 > 79 characters)

reviewbotreviewbot

E501 line too long (84 > 79 characters)

reviewbotreviewbot

E501 line too long (84 > 79 characters)

reviewbotreviewbot

We need to document the new sortable arg in here.

daviddavid

This needs an "Args" section.

daviddavid

This needs an "Args" section.

daviddavid

We can use a set comprehension here: ids = { review_request.get_last_activity_user_id() for review_request in object_list }

daviddavid

You're using this for every test case, so you can just add a class attribute: class LastUpdatedByColumnTests(BaseColumnTestCase): ... fixtures = …

daviddavid

Let's wrap this a little differently. Here and in the other test cases below: review_requests = [ self.create_review_request( summary='Test %d' …

daviddavid

If Review is used multiple times, wouldn't it be better to move this import statement to the global import at …

sheenaNgsheenaNg

This should be in the imperative mood ("Set" instead of "Sets")

daviddavid

Double backticks aren't necessary around the argument names here.

daviddavid

The first line of the docstring should be only one line, and should be in the imperative mood. If you …

daviddavid

This should be in the imperative mood ("Return" instead of "Returns"). This docstring also needs a "Returns" section.

daviddavid

id is a built-in for python. Can we use a different variable name?

daviddavid

Add a blank line between these two

daviddavid

We generally avoid the python ternary syntax because it's awkward and confusing. Please just use an if/else here.

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

KY
Review request changed

Commits:

Summary ID
[WIP] Add a "Last Updated By" column to the dashboard
7b33e37cb1dee88ab6e52169fa3be925b5050343
[WIP] Add a "Last Updated By" column to the dashboard
a3f74baa4fbd1a4bd1e3d51f95ca92855beaef4e
[WIP] First try at optimization of get_last_activity_info
14eafbbed32f57921e82e8ef7b1edd031c768e72

Diff:

Revision 2 (+324 -18)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

KY
KY
Review request changed

Change Summary:

Continue work on last_activity_info caching

Commits:

Summary ID
[WIP] Add a "Last Updated By" column to the dashboard
a3f74baa4fbd1a4bd1e3d51f95ca92855beaef4e
[WIP] First try at optimization of get_last_activity_info
264aece4fe399538a090f733f6e9cc37308a1801
[WIP] Add a "Last Updated By" column to the dashboard
018e55ee518b108bc942d575ff68b1acdaebb2a4
[WIP] First try at optimization of get_last_activity_info
705951a269741bc11d2dea018f3743311ea6232f
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
721be5b7d6c6ad3460166e9bf34b2889a4dbc3cb

Diff:

Revision 4 (+563 -71)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

KY
KY
KY
Review request changed

Change Summary:

Add tests for LastUpdatedByColumn

Commits:

Summary ID
[WIP] Add a "Last Updated By" column to the dashboard
62015796cb54bef579f56a6a08bb97239883f4d4
[WIP] First try at optimization of get_last_activity_info
84239ac84985eed852ecde343ffc61615a9e8cd7
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
46f16c0bb32a46cc1e4fa7fddb9d1a7c8e8945fb
Fix import error in review_request.py
0db77dfb14e2e4093e3f9643fc579adacc69ed45
Fix incorrect argument order
981da047d01ea23faa3cfadca804b7f48e452689
None handling for changedesc
ddf8a9844dc4a2e35d1587b3a475cff2b497dc28
Fetch users in Last Updated By column in one query
24b6b3f6c9bcbf7a20712a62330a02f6f53d798e
[WIP] Add a "Last Updated By" column to the dashboard
71393e085fd0c90ad31dfaac0cc93c90c985041f
[WIP] First try at optimization of get_last_activity_info
7f0126e01d9bee3253d4432c103e2909e33d4aa9
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
bcdd60cabd6578cee6ff30077e459bc250a65188
Fix import error in review_request.py
58b1f375667443f05860b22b5f2afda7123cbd04
Fix incorrect argument order
7d9e2b839e96e255740cad767042891a5a4417a9
None handling for changedesc
13fb9d7c4f0f91b1998a2d39496ecc1d0b1c2bb8
Fetch users in Last Updated By column in one query
c1db2c4bffc2e659dc82a9d89bbf96f4dc7205fe
Add LastUpdatedByColumnTests based on UsernameColumnTests
4cab6083d6dcb64f820f7f5682efe8833f9af438

Diff:

Revision 7 (+720 -90)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

KY
Review request changed

Commits:

Summary ID
[WIP] Add a "Last Updated By" column to the dashboard
71393e085fd0c90ad31dfaac0cc93c90c985041f
[WIP] First try at optimization of get_last_activity_info
7f0126e01d9bee3253d4432c103e2909e33d4aa9
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
bcdd60cabd6578cee6ff30077e459bc250a65188
Fix import error in review_request.py
58b1f375667443f05860b22b5f2afda7123cbd04
Fix incorrect argument order
7d9e2b839e96e255740cad767042891a5a4417a9
None handling for changedesc
13fb9d7c4f0f91b1998a2d39496ecc1d0b1c2bb8
Fetch users in Last Updated By column in one query
c1db2c4bffc2e659dc82a9d89bbf96f4dc7205fe
Add LastUpdatedByColumnTests based on UsernameColumnTests
4cab6083d6dcb64f820f7f5682efe8833f9af438
[WIP] Add a "Last Updated By" column to the dashboard
71393e085fd0c90ad31dfaac0cc93c90c985041f
[WIP] First try at optimization of get_last_activity_info
7f0126e01d9bee3253d4432c103e2909e33d4aa9
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
bcdd60cabd6578cee6ff30077e459bc250a65188
Fix import error in review_request.py
58b1f375667443f05860b22b5f2afda7123cbd04
Fix incorrect argument order
7d9e2b839e96e255740cad767042891a5a4417a9
None handling for changedesc
13fb9d7c4f0f91b1998a2d39496ecc1d0b1c2bb8
Fetch users in Last Updated By column in one query
c1db2c4bffc2e659dc82a9d89bbf96f4dc7205fe
Add LastUpdatedByColumnTests based on UsernameColumnTests
8f88d26b9b1c4523a447ac51b7cddb649cd1426b
Fix ReviewRequest.set_last_activity_info() failing when user is None
e97d9260bcc3a251bd94d65678092dd6d2ed38c2

Diff:

Revision 8 (+776 -94)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

KY
KY
KY
KY
david
  1. 
      
  2. reviewboard/datagrids/columns.py (Diff revision 11)
     
     
     
     
     
     
     
    Show all issues

    We need to document the new sortable arg in here.

  3. reviewboard/datagrids/columns.py (Diff revision 11)
     
     
     
    Show all issues

    This needs an "Args" section.

  4. reviewboard/datagrids/columns.py (Diff revision 11)
     
     
     
    Show all issues

    This needs an "Args" section.

  5. reviewboard/datagrids/columns.py (Diff revision 11)
     
     
     
     
     
    Show all issues

    We can use a set comprehension here:

    ids = {
        review_request.get_last_activity_user_id()
        for review_request in object_list
    }
    
  6. reviewboard/datagrids/tests.py (Diff revision 11)
     
     
    Show all issues

    You're using this for every test case, so you can just add a class attribute:

    class LastUpdatedByColumnTests(BaseColumnTestCase):
        ...
        fixtures = ['test_site']
        ...
        def test_render(self):
    
  7. reviewboard/datagrids/tests.py (Diff revision 11)
     
     
     
     
    Show all issues

    Let's wrap this a little differently. Here and in the other test cases below:

    review_requests = [
        self.create_review_request(
            summary='Test %d' % index,
            publish=True,
            submitter=username)
        for (index, username) in enumerate(usernames)
    ]
    

    In fact, since it looks like you are doing that for all the test methods, perhaps move this into a helper function?

  8. Show all issues

    This should be in the imperative mood ("Set" instead of "Sets")

  9. reviewboard/reviews/models/review_request.py (Diff revision 11)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Double backticks aren't necessary around the argument names here.

  10. reviewboard/reviews/models/review_request.py (Diff revision 11)
     
     
     
    Show all issues

    The first line of the docstring should be only one line, and should be in the imperative mood. If you need more detail for completenes, add additional paragraphs.

  11. Show all issues

    This should be in the imperative mood ("Return" instead of "Returns"). This docstring also needs a "Returns" section.

  12. Show all issues

    id is a built-in for python. Can we use a different variable name?

  13. reviewboard/reviews/models/review_request.py (Diff revision 11)
     
     
     
    Show all issues

    Add a blank line between these two

  14. Show all issues

    We generally avoid the python ternary syntax because it's awkward and confusing. Please just use an if/else here.

  15. 
      
sheenaNg
  1. 
      
  2. reviewboard/datagrids/columns.py (Diff revision 11)
     
     

    I wonder why is "state" being passed as a parameter in this method but it is not being used?

    1. I decided to add a state argument because the LastUpdatedByColumn, which inherits from UsernameColumn, needs it in this method, and there does not appear to be another way of getting the column state.

  3. Show all issues

    If Review is used multiple times, wouldn't it be better to move this import statement to the global import at the top of the file so there is no need to repeat this import statement multiple times?

    1. I believe the reason that Review is imported in this method and not the entire module is because it would otherwise result in a circular import between these modules.

  4. 
      
KY
Review request changed

Change Summary:

Make changes to address feedback

Commits:

Summary ID
[WIP] Add a "Last Updated By" column to the dashboard
1b53d5340a46a599c2d22eb0fa9c440d53848c4c
[WIP] First try at optimization of get_last_activity_info
6fecbb77249f2b9222955ab73179d1fa1e61cf06
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
5e23fb0645c4d5680e8251e164307e700fc04545
Fix import error in review_request.py
8453864ec2337dfd1ddd6dd81b60616632a954dc
Fix incorrect argument order
b8165390960fa8a5505f64a17cc2bac16179dadc
None handling for changedesc
d1343d9d645200ee6343726f80e582df8acc2522
Fetch users in Last Updated By column in one query
3024bc2c126ed04f27863acfd8a29d5b93542544
Add LastUpdatedByColumnTests based on UsernameColumnTests
e803fd9d8d43b0df5975ee87eae5a9b0313b0952
Fix ReviewRequest.set_last_activity_info() failing when user is None
94152736a6a625bc40f7c33b9e285b8b4039e4ba
Add info on Last Updated By column to dashboard documentation
818d1b480f7a7eec2732fd85b34ce621c6b895b4
Fix issues with review request closing updating last activity info
- Make closing a review request use the same timestamp for last_updated and the ChangeDescription - Fix test_get_last_activity_info_close
f448b444d7d5ef763f763febc926b338f8c6431a
Handle user being None in ReviewRequest.get_last_activity_user_id()
9efd28e73068f8e72b0a23ee095f359f5ba92c50
Make ReviewRequest.publish() set updated_object to diffset if it exists
86f3d157dc1370bc0d65b5077ef61866f18c9a3c
Update last activity info when review request is reopened
d431747bf9234be4e183845fe9621e4b8450ae2a
Fix last_updated being set incorrectly after publishing ReviewRequest
8342473afeb4756f0e0d6593b17a0a4400d5e1f0
Send the correct user in ReviewRequestLastUpdateResource
d92dc7159c6cf44137a3773cf038c9939eb699c7
Fix ReviewRequest.reopen() setting last activity info after no status change
80734ad6b2c671547724941c9357a9c85916701c
Add a "Last Updated By" column to the dashboard
2886dc701a7582abb5ab763c2d9c1fe7ba1d542b
First try at optimization of get_last_activity_info
347e5aa8a529bc8b6aaea55d331475446f4d3b63
Continue work on last_activity_info caching
* Update the cache when last activity changes * Add tests for get_last_activity_info * New: update last activity info when closing a review request
bba4df2b0cd2f382bb4eb2d88dd5a20cb92f9b22
Fix import error in review_request.py
9eead2a3139e9cec4e82a13c376d33fc558582f7
Fix incorrect argument order
19d8bb48e3e7a2ae0536196102556e00918acf96
None handling for changedesc
f568b695db1d1f7372b8dc53e5eee94aca606785
Fetch users in Last Updated By column in one query
3a44a50bec97041c994a6b7b342998c9c6f942f2
Add LastUpdatedByColumnTests based on UsernameColumnTests
410e1b643422b85781aa59d6a59f005b1c898c71
Fix ReviewRequest.set_last_activity_info() failing when user is None
b076ce9a7ead039ffb03c6e1f27b6775a31c712d
Add info on Last Updated By column to dashboard documentation
9dfd7179ef9462d8463a230e0769f7fa3b4e7dcb
Fix issues with review request closing updating last activity info
- Make closing a review request use the same timestamp for last_updated and the ChangeDescription - Fix test_get_last_activity_info_close
caf3389617783d8d0d40393f750381fba7424f8f
Handle user being None in ReviewRequest.get_last_activity_user_id()
d1b2f75efb0be1df4e8ba081ed3b5616be574067
Make ReviewRequest.publish() set updated_object to diffset if it exists
c3bd1a09f5a1ac7359cf7f89628067d86cd74a70
Update last activity info when review request is reopened
bb22a4b741f7ff917b1c4b1dce19afca681c5e95
Fix last_updated being set incorrectly after publishing ReviewRequest
2d5599330ffb81e6e5c02fc28c17c91ff6e88487
Send the correct user in ReviewRequestLastUpdateResource
cdb0cfc28c3f678a77d1f779daa05da483a6915c
Fix ReviewRequest.reopen() setting last activity info after no status change
3120d9fe3af41f0467404c49716457599d42ac3b
Make changes to address feedback
e606ba6247e22f74d4d40b1e28cc8d34de4549e8

Diff:

Revision 12 (+952 -186)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
Loading...