3445: ReviewRequest.get_last_activity() always returns the ReviewRequest itself

marc****@gmai***** (Google Code) (Is this you? Claim this profile.)
brennie
brennie
What version are you running?

Review Board 2.1 alpha 0 (dev)


What's the URL of the page containing the problem?

My local page.


What steps will reproduce the problem?
1. Add a review to a review request
2. Compare timestamps between the latest review and the last_updated field on the review request


What is the expected output? What do you see instead?

ReviewRequest.get_last_activity() always returns the ReviewRequest itself instead of any of the reviews. This is because the last_updated field on a ReviewRequest gets set to a time after the latest review, so there is never a review that is newer than the ReviewRequest itself.


What operating system are you using? What browser?

Ubuntu and Chrome


Please provide any additional information below.

I'm trying to write an extension that will display the last user to update a review request. However, ReviewRequest.get_last_activity() keeps returning the ReviewRequest itself, so it always displays the submitter's name.

I made an update as a different user than the one I submitted with and got this:

$ python reviewboard/manage.py shell
...
>>> from reviewboard.reviews.models.review_request import ReviewRequest as RR
>>> RR.objects.all()
[<ReviewRequest: Test1>]
>>> rr = RR.objects.all()[0]
>>> r = rr.reviews.filter(public=True).latest()
>>> r
<Review: Review of 'Test1'>
>>> r.timestamp
datetime.datetime(2014, 6, 26, 19, 46, 45, 65830, tzinfo=<UTC>)
>>> rr.last_updated
datetime.datetime(2014, 6, 26, 19, 46, 45, 153334, tzinfo=<UTC>)


Here is the code I was playing with:

extension.py:

class LastUpdatedByColumn(Column):                                                   
    def render_data(self, stateful_column, review_request):                     
        timestamp, updated_object = review_request.get_last_activity()
        if hasattr(updated_object, 'user'):
           return updated_object.user.username
        elif hasattr(updated_object, 'submitter'):
           return updated_object.submitter.username
        return '??? %s' % updated_object.__class__.__name__

class LastUpdatedBy(Extension):                                           
    metadata = {                                                                
        'Name': 'LastUpdatedBy',                                                
        'Summary': 'A column that displays who the last user was to update a review request.',
    }                                                                           
                                                                                
    def initialize(self):                                                       
        DashboardColumnsHook(self, [                                            
            LastUpdatedByColumn(id='lastUpdatedBy',                                  
                                label='Last Updated',                                
                                detailed_label='Last Updated By'),                   
                                shrink=True),                                       
        ])
#1 kvdgulik

This seems to be related to a bug in the review update notifications where the updates always contain the name of the user who created the request and not the user who updated the request.

#2 annic

I am working on this bug

  • +annic
#3 annic

The fix patch has been posted for reviewing, following is the link:
https://reviews.reviewboard.org/r/8800/

brennie
#4 brennie
  • -New
    +PendingReview
  • -annic
    +brennie
brennie
#5 brennie

This has been landed on release-3.0.x as 43c6fad4d97f3c5290332a27c4c4034dd46fc2a3 and will be included in the next minor release.

brennie
#6 brennie
  • -PendingReview
    +Fixed