Skip to content

Commit

Permalink
Merge pull request #2635 from actiontech/issue-1807-winfred-5
Browse files Browse the repository at this point in the history
modify: init stage of workflow in sql version stage
  • Loading branch information
ColdWaterLW authored Sep 26, 2024
2 parents 3d60d44 + 2e187c7 commit 909a7f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions sqle/model/sql_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ const (
WorkflowReleaseStatusHaveBeenReleased = "released"
WorkflowReleaseStatusNotNeedReleased = "not_need_release"
)

func (stage SqlVersionStage) InitialStatusOfWorkflow() string {
if len(stage.SqlVersionStagesDependency) > 0 && stage.SqlVersionStagesDependency[0].NextStageID == 0 {
return WorkflowReleaseStatusNotNeedReleased
}
return WorkflowReleaseStatusIsBingReleased
}
11 changes: 7 additions & 4 deletions sqle/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,14 @@ func (s *Storage) CreateWorkflowV2(subject, workflowId, desc string, user *User,
// get the first stage
err = tx.Model(&SqlVersionStage{}).
Preload("WorkflowVersionStage").
Preload("SqlVersionStagesDependency").
Where("sql_version_id = ?", sqlVersionId).
Order("stage_sequence ASC").First(stage).Error
} else {
// get specific stage
err = tx.Model(&SqlVersionStage{}).
Preload("WorkflowVersionStage").
Preload("SqlVersionStagesDependency").
Where("sql_version_id = ? AND id = ?", sqlVersionId, versionStageId).
First(stage).Error
}
Expand All @@ -614,10 +616,11 @@ func (s *Storage) CreateWorkflowV2(subject, workflowId, desc string, user *User,
}
// associate sql version with workflow
workflowVersionStageRelation := &WorkflowVersionStage{
WorkflowID: workflowId,
SqlVersionID: *sqlVersionId,
SqlVersionStageID: stage.ID,
WorkflowSequence: len(stage.WorkflowVersionStage) + 1,
WorkflowID: workflowId,
SqlVersionID: *sqlVersionId,
SqlVersionStageID: stage.ID,
WorkflowSequence: len(stage.WorkflowVersionStage) + 1,
WorkflowReleaseStatus: stage.InitialStatusOfWorkflow(),
}

err = tx.Create(workflowVersionStageRelation).Error
Expand Down

0 comments on commit 909a7f7

Please sign in to comment.