mirror of https://github.com/langgenius/dify.git
refactor: Use Repository Pattern for Model Layer (#27663)
This commit is contained in:
parent
8d0250eb2e
commit
5f8b37d1bf
|
|
@ -1219,9 +1219,13 @@ class Message(Base):
|
|||
@property
|
||||
def workflow_run(self):
|
||||
if self.workflow_run_id:
|
||||
from .workflow import WorkflowRun
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
return db.session.query(WorkflowRun).where(WorkflowRun.id == self.workflow_run_id).first()
|
||||
from repositories.factory import DifyAPIRepositoryFactory
|
||||
|
||||
session_maker = sessionmaker(bind=db.engine, expire_on_commit=False)
|
||||
repo = DifyAPIRepositoryFactory.create_api_workflow_run_repository(session_maker)
|
||||
return repo.get_workflow_run_by_id_without_tenant(run_id=self.workflow_run_id)
|
||||
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -1058,7 +1058,16 @@ class WorkflowAppLog(Base):
|
|||
|
||||
@property
|
||||
def workflow_run(self):
|
||||
return db.session.get(WorkflowRun, self.workflow_run_id)
|
||||
if self.workflow_run_id:
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from repositories.factory import DifyAPIRepositoryFactory
|
||||
|
||||
session_maker = sessionmaker(bind=db.engine, expire_on_commit=False)
|
||||
repo = DifyAPIRepositoryFactory.create_api_workflow_run_repository(session_maker)
|
||||
return repo.get_workflow_run_by_id_without_tenant(run_id=self.workflow_run_id)
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def created_by_account(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue