Corp/backend/commerce/tasks/__init__.py

14 lines
439 B
Python

from celery import shared_task
from commerce.integrations import sync_registered_source
@shared_task(name="commerce.sync_source")
def sync_source(source_code: str, entity_type: str):
results = sync_registered_source(source_code, entity_type=entity_type)
return {
"processed": len(results),
"created": sum(result.created for result in results),
"changed": sum(result.changed for result in results),
}