fix workflow count

This commit is contained in:
jxxghp
2025-03-15 10:16:25 +08:00
parent f5832d6a25
commit a0a11842cb
3 changed files with 5 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ def reset_workflow(workflow_id: int,
# 停止工作流
global_vars.stop_workflow(workflow_id)
# 重置工作流
workflow.reset(db, workflow_id)
workflow.reset(db, workflow_id, reset_count=True)
# 删除缓存
SystemConfigOper().delete(f"WorkflowCache-{workflow_id}")
return schemas.Response(success=True)

View File

@@ -83,12 +83,12 @@ class Workflow(Base):
@staticmethod
@db_update
def reset(db, wid: int):
def reset(db, wid: int, reset_count: bool = False):
db.query(Workflow).filter(Workflow.id == wid).update({
"state": 'W',
"result": None,
"current_action": None,
"run_count": 0,
"run_count": 0 if reset_count else Workflow.run_count,
})
return True

View File

@@ -61,8 +61,8 @@ class WorkflowOper(DbOper):
"""
return Workflow.update_current_action(self._db, wid, action_id, context)
def reset(self, wid: int) -> bool:
def reset(self, wid: int, reset_count: bool = False) -> bool:
"""
重置
"""
return Workflow.reset(self._db, wid)
return Workflow.reset(self._db, wid, reset_count=reset_count)