• 
      

    Refactor queries for the review request page.

    Review Request #8347 — Created Aug. 25, 2016 and submitted

    Information

    Review Board
    release-3.0.x
    1179d6c...

    Reviewers

    This change moves all the data querying logic out of the review_detail view
    into a new ReviewRequestPageData object. The view itself is now primarily
    concerned with computation of the etag, creation of the entries, and rendering
    of the template--as it should be. This new object documents its attributes, and
    is passed into the builtin fields which wish to use it to optimize their
    queries, rather than the old locals_vars hack, which I believe was possibly
    literally one of the gateways to hell.

    As I was doing this I cleaned up some code which was no longer used and moved
    some of the work from pre-etag to post-etag. This also changes some of the
    timestamp comparisons to work off of integers (ctimes) instead of datetimes,
    since before we had a few instances where we were comparing datetimes to 0.

    • Did lots of testing with a few different review requests with lots of change
      description and review boxes.
    • Ran unit tests.
    Description From Last Updated

    Col: 80 E501 line too long (117 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (81 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (113 > 79 characters)

    reviewbotreviewbot

    'GeneralComment' imported but unused

    reviewbotreviewbot

    'ScreenshotComment' imported but unused

    reviewbotreviewbot

    'FileAttachmentComment' imported but unused

    reviewbotreviewbot

    Col: 80 E501 line too long (117 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (81 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (113 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (117 > 79 characters)

    reviewbotreviewbot

    I know this was here before, but while updating this code, maybe move to a try/except KeyError, to reduce this …

    chipx86chipx86

    "great number more queries" sounds kinda odd. Maybe just "many more queries than necessary?"

    chipx86chipx86

    Col: 80 E501 line too long (81 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (113 > 79 characters)

    reviewbotreviewbot

    Let's say "The HTTP request object," just to help differentiate it from "review request" for those newer to the concepts.

    chipx86chipx86

    Missing period.

    chipx86chipx86

    Can you go into the details of the ctime additions in the description? I'm assuming they fix some bug.

    chipx86chipx86

    Col: 80 E501 line too long (117 > 79 characters)

    reviewbotreviewbot

    Col: 80 E501 line too long (117 > 79 characters)

    reviewbotreviewbot
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
    2. reviewboard/reviews/builtin_fields.py (Diff revision 1)
       
       
      Show all issues
      Col: 80
       E501 line too long (117 > 79 characters)
      
    3. reviewboard/reviews/detail.py (Diff revision 1)
       
       
      Show all issues
      Col: 80
       E501 line too long (81 > 79 characters)
      
    4. reviewboard/reviews/detail.py (Diff revision 1)
       
       
      Show all issues
      Col: 80
       E501 line too long (113 > 79 characters)
      
    5. reviewboard/reviews/views.py (Diff revision 1)
       
       
      Show all issues
       'GeneralComment' imported but unused
      
    6. reviewboard/reviews/views.py (Diff revision 1)
       
       
      Show all issues
       'ScreenshotComment' imported but unused
      
    7. reviewboard/reviews/views.py (Diff revision 1)
       
       
      Show all issues
       'FileAttachmentComment' imported but unused
      
    8. 
        
    david
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
    2. reviewboard/reviews/builtin_fields.py (Diff revision 2)
       
       
      Show all issues
      Col: 80
       E501 line too long (117 > 79 characters)
      
    3. reviewboard/reviews/detail.py (Diff revision 2)
       
       
      Show all issues
      Col: 80
       E501 line too long (81 > 79 characters)
      
    4. reviewboard/reviews/detail.py (Diff revision 2)
       
       
      Show all issues
      Col: 80
       E501 line too long (113 > 79 characters)
      
    5. 
        
    david
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
    2. reviewboard/reviews/builtin_fields.py (Diff revision 3)
       
       
      Show all issues
      Col: 80
       E501 line too long (117 > 79 characters)
      
    3. reviewboard/reviews/detail.py (Diff revision 3)
       
       
      Show all issues
      Col: 80
       E501 line too long (81 > 79 characters)
      
    4. reviewboard/reviews/detail.py (Diff revision 3)
       
       
      Show all issues
      Col: 80
       E501 line too long (113 > 79 characters)
      
    5. 
        
    david
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
    2. reviewboard/reviews/builtin_fields.py (Diff revision 4)
       
       
      Show all issues
      Col: 80
       E501 line too long (117 > 79 characters)
      
    3. 
        
    chipx86
    1. Very nice.

    2. reviewboard/reviews/builtin_fields.py (Diff revision 3)
       
       
       
       
      Show all issues

      I know this was here before, but while updating this code, maybe move to a try/except KeyError, to reduce this from two lookups to one?

      1. I thought about this when I was looking at this code, but replacing two O(1) lookups with one doesn't seem worth the uglier code (nested try/excepts to catch KeyError and then DoesNotExist)

      2. Yeah, that's fair.

    3. reviewboard/reviews/detail.py (Diff revision 3)
       
       
       
      Show all issues

      "great number more queries" sounds kinda odd. Maybe just "many more queries than necessary?"

    4. reviewboard/reviews/detail.py (Diff revision 3)
       
       
      Show all issues

      Let's say "The HTTP request object," just to help differentiate it from "review request" for those newer to the concepts.

    5. reviewboard/reviews/detail.py (Diff revision 3)
       
       
      Show all issues

      Missing period.

    6. reviewboard/reviews/views.py (Diff revision 3)
       
       
      Show all issues

      Can you go into the details of the ctime additions in the description? I'm assuming they fix some bug.

    7. 
        
    david
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/reviews/builtin_fields.py
          reviewboard/reviews/views.py
          reviewboard/reviews/detail.py
      
      
    2. reviewboard/reviews/builtin_fields.py (Diff revision 5)
       
       
      Show all issues
      Col: 80
       E501 line too long (117 > 79 characters)
      
    3. 
        
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (e9b6eda)