Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: add properties to retrieve created by account and end user in Wo… (#12129)

-LAN-4e76f2fc4411
diff --git a/api/models/workflow.py b/api/models/workflow.py
index 32a0860b77b..8642df8adb5 100644
--- a/api/models/workflow.py
+++ b/api/models/workflow.py
@@ -414,6 +414,18 @@ class WorkflowRun(db.Model): # type: ignore[name-defined]
finished_at = db.Column(db.DateTime)
exceptions_count = db.Column(db.Integer, server_default=db.text("0"))
+ @property
+ def created_by_account(self):
+ created_by_role = CreatedByRole(self.created_by_role)
+ return db.session.get(Account, self.created_by) if created_by_role == CreatedByRole.ACCOUNT else None
+
+ @property
+ def created_by_end_user(self):
+ from models.model import EndUser
+
+ created_by_role = CreatedByRole(self.created_by_role)
+ return db.session.get(EndUser, self.created_by) if created_by_role == CreatedByRole.END_USER else None
+
@property
def graph_dict(self):
return json.loads(self.graph) if self.graph else {}