refactor(demo): Standardize demo account type names across codebase
Standardize demo account type naming from inconsistent variants to clean names: - individual_bakery, professional_bakery → professional - central_baker, enterprise_chain → enterprise This eliminates naming confusion that was causing bugs in the demo session initialization, particularly for enterprise demo tenants where different parts of the system used different names for the same concept. Changes: - Updated source of truth in demo_session config - Updated all backend services (middleware, cloning, orchestration) - Updated frontend types, pages, and stores - Updated demo session models and schemas - Removed all backward compatibility code as requested Related to: Enterprise demo session access fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,34 @@ class DemoCleanupService:
|
||||
session.status = DemoSessionStatus.EXPIRED
|
||||
await self.db.commit()
|
||||
|
||||
# Delete session data
|
||||
# Check if this is an enterprise demo with children
|
||||
is_enterprise = session.demo_account_type == "enterprise"
|
||||
child_tenant_ids = []
|
||||
|
||||
if is_enterprise and session.session_metadata:
|
||||
child_tenant_ids = session.session_metadata.get("child_tenant_ids", [])
|
||||
|
||||
# Delete child tenants first (for enterprise demos)
|
||||
if child_tenant_ids:
|
||||
logger.info(
|
||||
"Cleaning up enterprise demo children",
|
||||
session_id=session.session_id,
|
||||
child_count=len(child_tenant_ids)
|
||||
)
|
||||
for child_id in child_tenant_ids:
|
||||
try:
|
||||
await self.data_cloner.delete_session_data(
|
||||
str(child_id),
|
||||
session.session_id
|
||||
)
|
||||
except Exception as child_error:
|
||||
logger.error(
|
||||
"Failed to delete child tenant",
|
||||
child_id=child_id,
|
||||
error=str(child_error)
|
||||
)
|
||||
|
||||
# Delete parent/main session data
|
||||
await self.data_cloner.delete_session_data(
|
||||
str(session.virtual_tenant_id),
|
||||
session.session_id
|
||||
@@ -92,6 +119,8 @@ class DemoCleanupService:
|
||||
logger.info(
|
||||
"Session cleaned up",
|
||||
session_id=session.session_id,
|
||||
is_enterprise=is_enterprise,
|
||||
children_deleted=len(child_tenant_ids),
|
||||
age_minutes=(now - session.created_at).total_seconds() / 60
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user