perf(organizations): cache and instrument API responses

This commit is contained in:
2026-05-14 16:14:45 +02:00
parent 6d1ec2e55c
commit 5fdd23ecc0
13 changed files with 603 additions and 33 deletions

View File

@@ -5,8 +5,8 @@ from __future__ import annotations
import logging
from celery import shared_task
from django.core.cache import cache
from organizations.cache import invalidate_organization_api_cache
from organizations.services import OrganizationDataSnapshotRefreshService
logger = logging.getLogger(__name__)
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
def refresh_all_organization_data_snapshots(batch_size: int = 100) -> dict:
"""Refresh all organization data snapshots for API v2."""
result = OrganizationDataSnapshotRefreshService.refresh(batch_size=batch_size)
cache.clear()
invalidate_organization_api_cache()
payload = {
"processed": result.processed,
"created": result.created,
@@ -39,7 +39,7 @@ def refresh_organization_data_snapshots_for_parser_batch(
batch_id=batch_id,
batch_size=batch_size,
)
cache.clear()
invalidate_organization_api_cache()
payload = {
"source": source,
"batch_id": batch_id,