feat: Implement statistics class & additional metrics

The new module/class helps us constructing queries and count records to
expose various statistics on the homepage. We also utilize for some new
prometheus metrics (package and user gauges).
Record counts are being cached with Redis.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-07-22 16:31:50 +02:00
parent 347c2ce721
commit 44c158b8c2
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
7 changed files with 143 additions and 89 deletions

View file

@ -26,11 +26,10 @@ def user() -> User:
yield user
@pytest.mark.asyncio
async def test_search_cache_metrics(user: User):
def test_search_cache_metrics(user: User):
# Fire off 3 identical queries for caching
for _ in range(3):
await db_query_cache("key", db.query(User))
db_query_cache("key", db.query(User))
# Get metrics
metrics = str(generate_latest(REGISTRY))