Fixing the review_request_updated JSON API

Review Request #802 — Created April 1, 2009 and discarded

Information

Review Board SVN (deprecated)

Reviewers

The current review_request_updated API determines if a review request has been updated based on the presence of any new reviews on the request.  What it does not take into account is whether or not the review request itself has been updated since last viewed by the user.  For example, a diff could be updated on the review request and the API would return false when in fact the review request has been updated.

This change attempts to fix the API by comparing the last_updated field on the ReviewRequest instance with the last time the user visited the review. 
Tested using a custom Review Board tool that utilizes the JSON API.  Is there a standard way to test JSON API changes?
chipx86
  1. 
      
  2. trunk/reviewboard/webapi/json.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
    This code should exist as a function (say, get_updated_since_last_visit(user)) in the ReviewRequest class in reviews/models.py. That way it's reusable and not limited to webapi.
    
    As far as testing, it's best if you could write a unit test or two or three for this in webapi/tests.py and/or reviews/models.py (for webapi and for the class's new function).
    1. This is all a lot easier now. Change the query to:
      
          review_requests = ReviewRequest.objects.public(request.user, with_counts=True)
      
      And then you can return 'updated' as:
      
          review_request.last_updated >= review_requests.last_review_timestamp  or review_request.new_review_count > 0
  3.