Skip to content
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

feat: get workflows with sql version and can filter by version #2630

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sqle/api/controller/v1/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ type WorkflowDetailResV1 struct {
Name string `json:"workflow_name"`
WorkflowId string `json:"workflow_id" `
Desc string `json:"desc"`
SqlVersionName string `json:"sql_version_name"`
SqlVersionName []string `json:"sql_version_name"`
CreateUser string `json:"create_user_name"`
CreateTime *time.Time `json:"create_time"`
CurrentStepType string `json:"current_step_type,omitempty" enums:"sql_review,sql_execute"`
Expand Down Expand Up @@ -657,6 +657,7 @@ func GetWorkflowsV1(c echo.Context) error {
limit, offset := controller.GetLimitAndOffset(req.PageIndex, req.PageSize)
data := map[string]interface{}{
"filter_workflow_id": req.FilterWorkflowID,
"filter_sql_version_id": req.FilterSqlVersionID,
"filter_subject": req.FilterSubject,
"filter_create_time_from": req.FilterCreateTimeFrom,
"filter_create_time_to": req.FilterCreateTimeTo,
Expand Down Expand Up @@ -705,6 +706,7 @@ func GetWorkflowsV1(c echo.Context) error {
CurrentStepType: workflow.CurrentStepType.String,
CurrentStepAssigneeUser: CurrentStepAssigneeUserNames,
Status: workflow.Status,
SqlVersionName: workflow.SqlVersionName,
}
workflowsResV1 = append(workflowsResV1, workflowRes)
}
Expand Down
5 changes: 4 additions & 1 deletion sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16648,7 +16648,10 @@ var doc = `{
"type": "string"
},
"sql_version_name": {
"type": "string"
"type": "array",
"items": {
"type": "string"
}
},
"status": {
"type": "string",
Expand Down
5 changes: 4 additions & 1 deletion sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -16632,7 +16632,10 @@
"type": "string"
},
"sql_version_name": {
"type": "string"
"type": "array",
"items": {
"type": "string"
}
},
"status": {
"type": "string",
Expand Down
4 changes: 3 additions & 1 deletion sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4218,7 +4218,9 @@ definitions:
project_name:
type: string
sql_version_name:
type: string
items:
type: string
type: array
status:
enum:
- wait_for_audit
Expand Down
10 changes: 9 additions & 1 deletion sqle/model/workflow_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type WorkflowListDetail struct {
CurrentStepAssigneeUserIds sql.NullString `json:"current_step_assignee_user_id_list"`
Status string `json:"status"`
TaskInstanceType RowList `json:"task_instance_type"`
SqlVersionName RowList `json:"version"`
}

var workflowsQueryTpl = `
Expand All @@ -30,7 +31,8 @@ SELECT
w.created_at AS create_time,
curr_wst.type AS current_step_type,
curr_ws.assignees AS current_step_assignee_user_id_list,
wr.status
wr.status,
GROUP_CONCAT(versions.version SEPARATOR ',') AS version
{{- template "body" . -}}
GROUP BY w.id
ORDER BY w.id DESC
Expand Down Expand Up @@ -59,6 +61,8 @@ LEFT JOIN workflow_instance_records wir on wir.workflow_record_id = wr.id
LEFT JOIN tasks ON wir.task_id = tasks.id
LEFT JOIN workflow_steps AS curr_ws ON wr.current_workflow_step_id = curr_ws.id
LEFT JOIN workflow_step_templates AS curr_wst ON curr_ws.workflow_step_template_id = curr_wst.id
LEFT JOIN workflow_version_stages AS stages ON stages.workflow_id = w.workflow_id
LEFT JOIN sql_versions AS versions ON stages.sql_version_id = versions.id

{{- if .check_user_can_access }}
LEFT JOIN workflow_steps AS all_ws ON w.id = all_ws.workflow_id AND all_ws.state !='initialized'
Expand Down Expand Up @@ -135,6 +139,10 @@ AND tasks.instance_id = :filter_task_instance_id
AND w.workflow_id = :filter_workflow_id
{{- end }}

{{- if .filter_sql_version_id }}
AND versions.id = :filter_sql_version_id
{{- end }}

{{- if .filter_project_id }}
AND w.project_id = :filter_project_id
{{- end }}
Expand Down
Loading