Optimize the screenshot, file attachment, and no-repository code paths.
Review Request #3251 — Created July 30, 2012 and submitted
Optimize the screenshot, file attachment, and no-repository code paths. The screenshot page was quite slow still, as it didn't take advantage of the new caching abilities in the models. We now have the query count down pretty extensively. File attachments on the review request page were pretty costly too, due to a special template tag we have that serializes all the file attachment comments. The problem there was that we weren't accessing the right caches. Primarily, they were accessing comments directly. FileAttachment and Screenshot both have get_comments() functions that both return from the cache and sets it, which solves this. Review requests without repositories were still trying to compute diffs, which was a waste of effort. This happened on the review request page, screenshot page, and on the Last Updated check. Now we skip these if there are no repositories. This skipping is done in a new convenience method, ReviewRequest.get_diffsets.
The query counts on the screenshot page and for review requests with file attachments went down to the same levels as standard review request pages. Review requests with no repository decreased in size a bit.