Add cached statistics for LocalSites.
Review Request #12303 — Created May 26, 2022 and submitted
Information | |
---|---|
chipx86 | |
Review Board | |
release-5.0.x | |
Reviewers | |
reviewboard | |
This introduces
LocalSiteManager
, which is the new manager for
LocalSite
objects. It provides methods used to quickly make
determinations about the Local Site usage on the server.The main method currently is
get_stats()
, which returns a dictionary
containing:
- The total number of Local Sites on the server
- The number of public Local Sites
- The number of private Local Sites
- A UUID representing the generated state (which can be used as a
component of other cache keys to enable automatic invalidation)This is cached and invalidated any time a
LocalSite
is created,
deleted, or if thepublic
state has changed, making it fast and
reliable for lookups.There are additional wrappers around this that leverage the cached
state. These include:
has_local_sites()
has_public_local_sites()
has_private_local_sites()
These will soon be used to make some parts of our queries conditional on
their presence, letting us simplify queries in the common case.
Unit tests pass.
Change Summary:
- Added
state_uuid
to theget_stats()
results, which can be used for other cache keys for automatic invalidation. - Removed some effectively duplicate unit tests around invalidation.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+1068 -6) |
Checks run (2 succeeded)
Description: |
|
---|

-
-
reviewboard/site/managers.py (Diff revision 1) I've noticed there's different ways you write out the class for
:py:class
in the doc strings:
1. the way on this line
2. ":py:class:LocalSite
" on line 59
3. ":py:class:~reviewboard.site.models.LocalSite
" on line 185What's the difference between these and why use different ways?
-
reviewboard/testing/testcase.py (Diff revision 1) I think this is supposed to be
name=self.local_site_name
. Also instead it might be good to change the defaultname
value to a LocalSite that doesn't exist, so that the default use doesn't trigger the assert?
Change Summary:
Updated a
:py:class:
reference toLocalSite
to use the full class path.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+1070 -6) |