-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add workflow run entity #6622
Add workflow run entity #6622
Conversation
thomtrp
commented
Aug 14, 2024
- create a workflow run every time a workflow is triggered in not_started status. This status will be helpful later for once workflows will be scheduled
- update run status once workflow starts running
- complete status once the workflow finished running
- add a failed status if an error occurs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request introduces a new WorkflowRunWorkspaceEntity to track the execution of workflows, implementing functionality to create, update, and manage workflow run statuses throughout the workflow execution process.
- Added WorkflowRunWorkspaceEntity in
workflow-run.workspace-entity.ts
with fields for start/end times and status - Implemented WorkflowStatusService in
workflow-status.service.ts
to manage workflow run lifecycle (create, start, end) - Updated WorkflowRunnerJob in
workflow-runner.job.ts
to use WorkflowStatusService for tracking run progress - Modified WorkflowEventTriggerJob in
workflow-event-trigger.job.ts
to create a workflow run before execution - Introduced WorkflowStatusException in
workflow-status.exception.ts
for handling specific workflow status errors
13 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings
icon: 'IconHistory', | ||
}) | ||
@WorkspaceIsNullable() | ||
status: WorkflowRunStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider making status non-nullable to ensure it always has a valid value
.../twenty-server/src/modules/workflow/common/standard-objects/workflow-run.workspace-entity.ts
Show resolved
Hide resolved
const onGoingWorkflowRuns = ( | ||
await workflowRunDataSource.findBy({ | ||
workflowVersionId, | ||
}) | ||
).filter((workflow) => | ||
[WorkflowRunStatus.NOT_STARTED, WorkflowRunStatus.RUNNING].includes( | ||
workflow.status, | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a database query to filter ongoing workflow runs instead of fetching all and filtering in memory. This approach may not scale well with a large number of workflow runs.
|
||
if (onGoingWorkflowRuns.length > 0) { | ||
throw new WorkflowStatusException( | ||
'There is already an on going workflow run', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: 'on going' should be 'ongoing'
'There is already an on going workflow run', | |
'There is already an ongoing workflow run', |
a2fd157
to
e4ed6e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
.../twenty-server/src/modules/workflow/common/standard-objects/workflow-run.workspace-entity.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/modules/workflow/workflow-runner/workflow-runner.service.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/modules/workflow/workflow-status/workflow-status.module.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-event-trigger.job.ts
Show resolved
Hide resolved
...ages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-trigger-job.module.ts
Outdated
Show resolved
Hide resolved
f5e87d9
to
b80e83b
Compare