Add user delete process 2
This commit is contained in:
@@ -43,7 +43,7 @@ class AlertProcessorTenantDeletionService(BaseTenantDataDeletionService):
|
||||
# Count alerts (CASCADE will delete alert_interactions)
|
||||
alert_count = await self.db.scalar(
|
||||
select(func.count(Alert.id)).where(
|
||||
Alert.tenant_id == UUID(tenant_id)
|
||||
Alert.tenant_id == tenant_id
|
||||
)
|
||||
)
|
||||
preview["alerts"] = alert_count or 0
|
||||
@@ -53,7 +53,7 @@ class AlertProcessorTenantDeletionService(BaseTenantDataDeletionService):
|
||||
from app.models.alerts import AlertInteraction
|
||||
interaction_count = await self.db.scalar(
|
||||
select(func.count(AlertInteraction.id)).where(
|
||||
AlertInteraction.tenant_id == UUID(tenant_id)
|
||||
AlertInteraction.tenant_id == tenant_id
|
||||
)
|
||||
)
|
||||
preview["alert_interactions"] = interaction_count or 0
|
||||
@@ -61,7 +61,7 @@ class AlertProcessorTenantDeletionService(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
|
||||
@@ -113,7 +113,7 @@ class AlertProcessorTenantDeletionService(BaseTenantDataDeletionService):
|
||||
logger.info("alert_processor.tenant_deletion.deleting_interactions", tenant_id=tenant_id)
|
||||
interactions_result = await self.db.execute(
|
||||
delete(AlertInteraction).where(
|
||||
AlertInteraction.tenant_id == UUID(tenant_id)
|
||||
AlertInteraction.tenant_id == tenant_id
|
||||
)
|
||||
)
|
||||
result.deleted_counts["alert_interactions"] = interactions_result.rowcount
|
||||
@@ -127,7 +127,7 @@ class AlertProcessorTenantDeletionService(BaseTenantDataDeletionService):
|
||||
logger.info("alert_processor.tenant_deletion.deleting_alerts", tenant_id=tenant_id)
|
||||
alerts_result = await self.db.execute(
|
||||
delete(Alert).where(
|
||||
Alert.tenant_id == UUID(tenant_id)
|
||||
Alert.tenant_id == tenant_id
|
||||
)
|
||||
)
|
||||
result.deleted_counts["alerts"] = alerts_result.rowcount
|
||||
@@ -141,7 +141,7 @@ class AlertProcessorTenantDeletionService(BaseTenantDataDeletionService):
|
||||
logger.info("alert_processor.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
|
||||
|
||||
Reference in New Issue
Block a user