fix demo session 1
This commit is contained in:
@@ -98,8 +98,37 @@ class DemoCleanupService:
|
||||
# Delete child tenants if enterprise
|
||||
if session.demo_account_type == "enterprise" and session.session_metadata:
|
||||
child_tenant_ids = session.session_metadata.get("child_tenant_ids", [])
|
||||
logger.info(
|
||||
"Deleting child tenant data",
|
||||
session_id=session_id,
|
||||
child_count=len(child_tenant_ids)
|
||||
)
|
||||
|
||||
for child_tenant_id in child_tenant_ids:
|
||||
await self._delete_from_all_services(child_tenant_id)
|
||||
child_results = await self._delete_from_all_services(str(child_tenant_id))
|
||||
|
||||
# Aggregate child deletion results
|
||||
for (service_name, _), child_result in zip(self.services, child_results):
|
||||
if isinstance(child_result, Exception):
|
||||
logger.warning(
|
||||
"Failed to delete child tenant data from service",
|
||||
service=service_name,
|
||||
child_tenant_id=child_tenant_id,
|
||||
error=str(child_result)
|
||||
)
|
||||
else:
|
||||
child_deleted = child_result.get("records_deleted", {}).get("total", 0)
|
||||
total_deleted += child_deleted
|
||||
|
||||
# Update details to track child deletions
|
||||
if service_name not in details:
|
||||
details[service_name] = {"child_deletions": []}
|
||||
if "child_deletions" not in details[service_name]:
|
||||
details[service_name]["child_deletions"] = []
|
||||
details[service_name]["child_deletions"].append({
|
||||
"child_tenant_id": str(child_tenant_id),
|
||||
"records_deleted": child_deleted
|
||||
})
|
||||
|
||||
duration_ms = int((datetime.now(timezone.utc) - start_time).total_seconds() * 1000)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user