Skip to content

Remove unnecessary SQL queries from avatar requests

What does this MR do?

Quoting from #33777 (comment 237783255):

  1. Loading the model for the upload. (In this case, the user.) We can't avoid this. However, we do memoize this at the wrong point and so do it twice.
  2. Loading the upload record for the upload. We also can't avoid this. We could try to bundle it with 1, but I don't think it's worth it right now.
  3. Loading gon variables, specifically for feature flags. We can and should avoid this.
  4. Loading identities. This comes from a password expiration check which will redirect in some circumstances. We can and should avoid this, as you can view the file unauthenticated anyway. Also, redirecting an image request is unlikely to do anything useful.

The first commit here fixes item 1. The second commit fixes items 3 and 4.

Merge request reports