Add organizations v2 API and registry enrichment
This commit is contained in:
37
src/organizations/tasks.py
Normal file
37
src/organizations/tasks.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Celery tasks for organizations snapshots."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from celery import shared_task
|
||||
from django.core.cache import cache
|
||||
|
||||
from organizations.services import OrganizationDataSnapshotRefreshService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@shared_task
|
||||
def refresh_organization_data_snapshots_for_parser_batch(
|
||||
*,
|
||||
source: str,
|
||||
batch_id: int,
|
||||
batch_size: int = 100,
|
||||
) -> dict:
|
||||
"""Refresh snapshots for organizations affected by one parser batch."""
|
||||
result = OrganizationDataSnapshotRefreshService.refresh_for_parser_batch(
|
||||
source=source,
|
||||
batch_id=batch_id,
|
||||
batch_size=batch_size,
|
||||
)
|
||||
cache.clear()
|
||||
payload = {
|
||||
"source": source,
|
||||
"batch_id": batch_id,
|
||||
"processed": result.processed,
|
||||
"created": result.created,
|
||||
"updated": result.updated,
|
||||
}
|
||||
logger.info("Organization data snapshots refreshed: %s", payload)
|
||||
return payload
|
||||
Reference in New Issue
Block a user