Add cached statistics for a Local Site's ACLs.

Review Request #12304 — Created May 27, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

This introduces a new manager stats method,
LocalSiteManager.get_local_site_acl_stats(). This returns a dictionary
containing:

  1. The number of users on the Local Site
  2. The number of admins on the Local Site
  3. Whether the Local Site is public
  4. A UUID representing the generated state (which can be used as a
    component of other cache keys to enable automatic invalidation)

This is per-Local Site. It exists on the manager so that either a
pre-fetched LocalSite instance can be provided, or the primary key of
a LocalSite. That makes it usable in methods where we may not yet want
to fetch a LocalSite.

This information is cached. It's invalidated whenever user/admin
membership changes, when public does or may have changed (based on
whether LocalSite.save() is called with/without update_fields=), or
when a LocalSite is deleted.

This will soon be used by other query-generating code to conditionally
fetch data from the database, and as components for other cache keys.

Unit tests pass.

Commits

Files

    Loading...