Skip to content
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
3 changes: 3 additions & 0 deletions sqle/api/controller/v2/dashboard/workflow_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ type ExportGlobalWorkflowReqV2 struct {
FilterCreateTimeTo string `json:"filter_create_time_to" query:"filter_create_time_to"`
FilterUpdateTimeFrom string `json:"filter_update_time_from" query:"filter_update_time_from"`
FilterUpdateTimeTo string `json:"filter_update_time_to" query:"filter_update_time_to"`
// FilterByOpsTypeUID 按运维类型单选筛选(空则不筛;不提供「未设置」;对 SQL 上线与数据导出均生效;语义与 GetGlobalWorkflowListReqV2 对齐)
FilterByOpsTypeUID string `json:"filter_by_ops_type_uid" query:"filter_by_ops_type_uid"`

FilterCard dashboard_svc.GlobalWorkflowFilterCard `json:"filter_card" query:"filter_card" valid:"omitempty,oneof=archived pending_for_me initiated_by_me view_all" enums:"archived,pending_for_me,initiated_by_me,view_all"`

Expand Down Expand Up @@ -148,6 +150,7 @@ type ExportGlobalWorkflowReqV2 struct {
// @Param filter_create_user_id query string false "filter by create user id"
// @Param filter_create_time_from query string false "filter create time from"
// @Param filter_create_time_to query string false "filter create time to"
// @Param filter_by_ops_type_uid query string false "filter by ops type dictionary item uid; empty means no filter; applies to sql_release and data_export; same semantics as GET /v2/dashboard/workflows"
// @Param export_format query string false "export format: csv or excel, default csv" Enums(csv,excel)
// @Success 200 {file} file "export workflow"
// @Router /v2/dashboard/workflows/exports [get]
Expand Down
13 changes: 6 additions & 7 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11677,6 +11677,12 @@ var doc = `{
"name": "filter_create_time_to",
"in": "query"
},
{
"type": "string",
"description": "filter by ops type dictionary item uid; empty means no filter; applies to sql_release and data_export; same semantics as GET /v2/dashboard/workflows",
"name": "filter_by_ops_type_uid",
"in": "query"
},
{
"enum": [
"csv",
Expand Down Expand Up @@ -14326,10 +14332,6 @@ var doc = `{
"dashboard.GlobalWorkflowListItem": {
"type": "object",
"properties": {
"assignee": {
"description": "当前处理人姓名",
"type": "string"
},
"create_user_name": {
"type": "string"
},
Expand Down Expand Up @@ -16762,9 +16764,6 @@ var doc = `{
"db_type": {
"type": "string"
},
"default_port": {
"type": "integer"
},
"params": {
"type": "array",
"items": {
Expand Down
13 changes: 6 additions & 7 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11661,6 +11661,12 @@
"name": "filter_create_time_to",
"in": "query"
},
{
"type": "string",
"description": "filter by ops type dictionary item uid; empty means no filter; applies to sql_release and data_export; same semantics as GET /v2/dashboard/workflows",
"name": "filter_by_ops_type_uid",
"in": "query"
},
{
"enum": [
"csv",
Expand Down Expand Up @@ -14310,10 +14316,6 @@
"dashboard.GlobalWorkflowListItem": {
"type": "object",
"properties": {
"assignee": {
"description": "当前处理人姓名",
"type": "string"
},
"create_user_name": {
"type": "string"
},
Expand Down Expand Up @@ -16746,9 +16748,6 @@
"db_type": {
"type": "string"
},
"default_port": {
"type": "integer"
},
"params": {
"type": "array",
"items": {
Expand Down
10 changes: 5 additions & 5 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ definitions:
type: object
dashboard.GlobalWorkflowListItem:
properties:
assignee:
description: 当前处理人姓名
type: string
create_user_name:
type: string
created_at:
Expand Down Expand Up @@ -1860,8 +1857,6 @@ definitions:
properties:
db_type:
type: string
default_port:
type: integer
params:
items:
$ref: '#/definitions/v1.InstanceAdditionalParamResV1'
Expand Down Expand Up @@ -15779,6 +15774,11 @@ paths:
in: query
name: filter_create_time_to
type: string
- description: filter by ops type dictionary item uid; empty means no filter;
applies to sql_release and data_export; same semantics as GET /v2/dashboard/workflows
in: query
name: filter_by_ops_type_uid
type: string
- description: 'export format: csv or excel, default csv'
enum:
- csv
Expand Down
37 changes: 35 additions & 2 deletions sqle/server/workflowexport/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,22 @@ func BuildGlobalSQLReleaseExport(ctx context.Context, workflowIDs []string, proj
return nil, nil, err
}
header := buildGlobalSQLReleaseHeader(ctx)
opsTypeNameByProject := map[string]map[string]string{}
rows := make([][]string, 0)
for _, workflow := range workflows {
projectUID := string(workflow.ProjectId)
projectName := ""
if projectNameByUID != nil {
projectName = projectNameByUID[string(workflow.ProjectId)]
projectName = projectNameByUID[projectUID]
}
opsTypeNameByUID, ok := opsTypeNameByProject[projectUID]
if !ok {
opsTypeNameByUID = dms.BuildOpsTypeNameMap(ctx, projectUID)
opsTypeNameByProject[projectUID] = opsTypeNameByUID
}
opsTypeName := ""
if ot := dms.ResolveOpsTypeFromMap(workflow.OpsTypeUID, opsTypeNameByUID); ot != nil {
opsTypeName = ot.Name
}
auditRecord := formatAuditRecordFromSQLSteps(ctx, workflow.AuditStepList())
for _, instanceRecord := range workflow.Record.InstanceRecords {
Expand All @@ -124,6 +135,7 @@ func BuildGlobalSQLReleaseExport(ctx context.Context, workflowIDs []string, proj
workflow.WorkflowId,
workflow.Subject,
workflow.Desc,
opsTypeName,
instanceName,
workflow.Model.CreatedAt.Format(timeLayout),
dms.GetUserNameWithDelTag(workflow.CreateUserId),
Expand Down Expand Up @@ -153,6 +165,7 @@ type DataExportExportRecord struct {
CreatedAt string
CreatorName string
UnifiedStatus string
OpsTypeName string
AuditRecord string
SQLContent string
ExportExecTime string
Expand All @@ -168,6 +181,7 @@ func FromListDataExportWorkflow(r *dmsV1.ListDataExportWorkflow) DataExportExpor
CreatedAt: r.CreatedAt.Format(timeLayout),
CreatorName: r.Creater.Name, //nolint:misspell // DMS API field is Creater
UnifiedStatus: mapDataExportStatus(r.Status),
OpsTypeName: opsTypeNameFromListDataExport(r),
}
if r.ProjectInfo != nil {
out.ProjectName = r.ProjectInfo.ProjectName
Expand Down Expand Up @@ -235,6 +249,7 @@ func BuildGlobalDataExportExport(ctx context.Context, records []DataExportExport
r.WorkflowID,
r.WorkflowName,
r.Description,
r.OpsTypeName,
strings.Join(r.DBServiceNames, ","),
r.CreatedAt,
r.CreatorName,
Expand All @@ -258,6 +273,7 @@ type CommonExportRow struct {
CreatorName string
CreatedAt string
Status string
OpsTypeName string
DataSource string
SQLContent string
SortKey string
Expand All @@ -277,6 +293,7 @@ func BuildGlobalCommonExport(ctx context.Context, rowsIn []CommonExportRow) ([]s
r.CreatorName,
r.CreatedAt,
r.Status,
r.OpsTypeName,
r.DataSource,
r.SQLContent,
})
Expand Down Expand Up @@ -363,6 +380,7 @@ func buildGlobalSQLReleaseHeader(ctx context.Context) []string {
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowNumber),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowName),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowDescription),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportOpsType),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportDataSource),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreateTime),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreator),
Expand All @@ -382,6 +400,7 @@ func buildGlobalDataExportHeader(ctx context.Context) []string {
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowNumber),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowName),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportWorkflowDescription),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportOpsType),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportDataSource),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreateTime),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreator),
Expand All @@ -403,6 +422,7 @@ func buildGlobalCommonHeader(ctx context.Context) []string {
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreator),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportCreateTime),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportTaskOrderStatus),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportOpsType),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportDataSource),
locale.Bundle.LocalizeMsgByCtx(ctx, locale.WFExportSQLContentPlain),
}
Expand Down Expand Up @@ -608,6 +628,7 @@ func BuildCommonRowsFromSQLRelease(ctx context.Context, workflowIDs []string, pr
return nil, err
}
typeLabel := LocalizeWorkflowTypeSQLRelease(ctx)
opsTypeNameByProject := map[string]map[string]string{}
out := make([]CommonExportRow, 0, len(workflows))
for _, workflow := range workflows {
names := make([]string, 0, len(workflow.Record.InstanceRecords))
Expand All @@ -620,9 +641,19 @@ func BuildCommonRowsFromSQLRelease(ctx context.Context, workflowIDs []string, pr
sqlBuilder.WriteString(getExecuteSqlList(ir.Task.ExecuteSQLs))
}
}
projectUID := string(workflow.ProjectId)
projectName := ""
if projectNameByUID != nil {
projectName = projectNameByUID[string(workflow.ProjectId)]
projectName = projectNameByUID[projectUID]
}
opsTypeNameByUID, ok := opsTypeNameByProject[projectUID]
if !ok {
opsTypeNameByUID = dms.BuildOpsTypeNameMap(ctx, projectUID)
opsTypeNameByProject[projectUID] = opsTypeNameByUID
}
opsTypeName := ""
if ot := dms.ResolveOpsTypeFromMap(workflow.OpsTypeUID, opsTypeNameByUID); ot != nil {
opsTypeName = ot.Name
}
created := workflow.Model.CreatedAt.Format(timeLayout)
out = append(out, CommonExportRow{
Expand All @@ -634,6 +665,7 @@ func BuildCommonRowsFromSQLRelease(ctx context.Context, workflowIDs []string, pr
CreatorName: dms.GetUserNameWithDelTag(workflow.CreateUserId),
CreatedAt: created,
Status: localizeUnifiedStatus(ctx, mapSQLWorkflowStatus(workflow.Record.Status)),
OpsTypeName: opsTypeName,
DataSource: strings.Join(names, ","),
SQLContent: sqlBuilder.String(),
SortKey: created,
Expand All @@ -656,6 +688,7 @@ func BuildCommonRowsFromDataExport(ctx context.Context, records []DataExportExpo
CreatorName: r.CreatorName,
CreatedAt: r.CreatedAt,
Status: localizeUnifiedStatus(ctx, r.UnifiedStatus),
OpsTypeName: r.OpsTypeName,
DataSource: strings.Join(r.DBServiceNames, ","),
SQLContent: r.SQLContent,
SortKey: r.CreatedAt,
Expand Down
11 changes: 11 additions & 0 deletions sqle/server/workflowexport/export_list_ops_type_ce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build !enterprise
// +build !enterprise

package workflowexport

import dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"

// opsTypeNameFromListDataExport is a CE stub: CE vendor ListDataExportWorkflow has no OpsType field.
func opsTypeNameFromListDataExport(_ *dmsV1.ListDataExportWorkflow) string {
return ""
}
Loading
Loading