Skip to content

Commit

Permalink
fix: add properties to retrieve created by account and end user in Wo…
Browse files Browse the repository at this point in the history
…rkflowRun model

Signed-off-by: -LAN- <[email protected]>
  • Loading branch information
laipz8200 committed Dec 26, 2024
1 parent cf00ee4 commit 2542efe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down

0 comments on commit 2542efe

Please sign in to comment.