Fix and improve loading of cached profiles in User.

Review Request #12318 — Created May 31, 2022 and submitted

Information

Review Board
release-5.0.x

Reviewers

User.get_profile() attempts to cache or make use of a cached result
from a previous call. It used to make use of _profile_set_cache, which
was the name used in Django 1.6 and 1.11. Newer versions use different
mechanisms for cache, for both prefetch_related() and
select_related(). This was a regression from Review Board 4.

This change fixes that support and expands upon it. A new series of unit
tests have been added that ensure caching works exactly as expected in a
variety of situations.

As part of this, various datagrid unit tests have been updated to once
again have reduced query counts. These counts were initially increased
in commit ceab149f415ade7432a3ff6e625beb0cdc5645f2, thought to have been
due to middleware changes, but were actually due to the Django relation
caching changes.

Unit tests pass.

Summary ID
Fix and improve loading of cached profiles in User.
`User.get_profile()` attempts to cache or make use of a cached result from a previous call. It used to make use of `_profile_set_cache`, which was the name used in Django 1.6 and 1.11. Newer versions use different mechanisms for cache, for both `prefetch_related()` and `select_related()`. This was a regression from Review Board 4. This change fixes that support and expands upon it. A new series of unit tests have been added that ensure caching works exactly as expected in a variety of situations. As part of this, various datagrid unit tests have been updated to once again have reduced query counts. These counts were initially increased in commit ceab149f415ade7432a3ff6e625beb0cdc5645f2, thought to have been due to middleware changes, but were actually due to the Django relation caching changes.
d0f07b574c0896686d6980a02f962f2d190e3e98
Description From Last Updated

F841 local variable 'profile' is assigned to but never used

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.0.x (ee0f51e)