• 
      

    Add User.get_local_site_stats for LocalSite membership info.

    Review Request #12310 — Created May 31, 2022 and submitted — Latest diff uploaded

    Information

    Review Board
    release-5.0.x

    Reviewers

    This introduces User.get_local_site_stats(), which provides a list of
    IDs of LocalSites that the user is a member of, and LocalSites that the
    user is an admin of, along with a state_uuid that can be used as part
    of derived cache keys.

    This enables quick lookup of LocalSite membership. The results are
    cached, making it quick to call, saving up two database queries,
    depending on the usage. The cache key makes use of the state_uuid from
    LocalSite.objects.get_stats(), meaning that the cache will
    automatically be invalidated any time the list of LocalSites change.

    User.is_admin_for_user() makes use of this, benefiting from the cache.
    The old version of this function did have a cached copy, but it didn't
    correctly invalidate.

    Unit tests pass.

    Commits

    Files