diff --git a/api/services/workflow_app_service.py b/api/services/workflow_app_service.py index 615a1c3093..7d313bbc30 100644 --- a/api/services/workflow_app_service.py +++ b/api/services/workflow_app_service.py @@ -89,17 +89,15 @@ class WorkflowAppService: account = session.scalar( select(Account).where(Account.email == created_by_account) ) - if account: - stmt = stmt.join( - Account, - and_( - WorkflowAppLog.created_by == Account.id, - WorkflowAppLog.created_by_role == CreatorUserRole.ACCOUNT, - Account.id == account.id, - ), - ) - else: - stmt = stmt.where(False) + account_id = account.id if account else None + stmt = stmt.join( + Account, + and_( + WorkflowAppLog.created_by == Account.id, + WorkflowAppLog.created_by_role == CreatorUserRole.ACCOUNT, + Account.id == account_id, + ), + ) stmt = stmt.order_by(WorkflowAppLog.created_at.desc()) diff --git a/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py b/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py index ce33116222..9e0510a0f7 100644 --- a/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py +++ b/api/tests/test_containers_integration_tests/services/test_workflow_app_service.py @@ -826,7 +826,7 @@ class TestWorkflowAppService: page=1, limit=20 ) - assert result_with_old_email["total"] == 0 + assert result_with_unknown_email["total"] == 0 account.email = original_email db_session_with_containers.commit()