Add user delete process 2

This commit is contained in:
Urtzi Alfaro
2025-10-31 18:57:58 +01:00
parent 269d3b5032
commit f44d235c6d
15 changed files with 166 additions and 145 deletions

View File

@@ -61,7 +61,7 @@ class ExternalTenantDeletionService(BaseTenantDataDeletionService):
# Count tenant-specific weather data (if any)
weather_count = await self.db.scalar(
select(func.count(WeatherData.id)).where(
WeatherData.tenant_id == UUID(tenant_id)
WeatherData.tenant_id == tenant_id
)
)
preview["tenant_weather_data"] = weather_count or 0
@@ -69,7 +69,7 @@ class ExternalTenantDeletionService(BaseTenantDataDeletionService):
# Count audit logs
audit_count = await self.db.scalar(
select(func.count(AuditLog.id)).where(
AuditLog.tenant_id == UUID(tenant_id)
AuditLog.tenant_id == tenant_id
)
)
preview["audit_logs"] = audit_count or 0
@@ -119,7 +119,7 @@ class ExternalTenantDeletionService(BaseTenantDataDeletionService):
logger.info("external.tenant_deletion.deleting_weather_data", tenant_id=tenant_id)
weather_result = await self.db.execute(
delete(WeatherData).where(
WeatherData.tenant_id == UUID(tenant_id)
WeatherData.tenant_id == tenant_id
)
)
result.deleted_counts["tenant_weather_data"] = weather_result.rowcount
@@ -133,7 +133,7 @@ class ExternalTenantDeletionService(BaseTenantDataDeletionService):
logger.info("external.tenant_deletion.deleting_audit_logs", tenant_id=tenant_id)
audit_result = await self.db.execute(
delete(AuditLog).where(
AuditLog.tenant_id == UUID(tenant_id)
AuditLog.tenant_id == tenant_id
)
)
result.deleted_counts["audit_logs"] = audit_result.rowcount