From b017385d7fe42e01c0acaf544236710eef9f0223 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 13:03:02 +0800 Subject: [PATCH 01/10] Mobile filter ticket success status filter, --- sqle/api/controller/v2/workflow.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index 02b68ea98e..2d4f866ee6 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -263,17 +263,15 @@ func GetWorkflowsV2(c echo.Context) error { var taskStatus string // task status - switch req.FilterStatus { - case model.WorkflowStatusExecFailed: + if req.FilterStatus == model.WorkflowStatusExecFailed { taskStatus = model.TaskStatusExecuteFailed - case model.WorkflowStatusFinish: - taskStatus = model.TaskStatusExecuteSucceeded + workflowStatus = model.WorkflowStatusFinish } // workflow status switch req.FilterStatus { case model.WorkflowStatusWaitForAudit, model.WorkflowStatusWaitForExecution, model.WorkflowStatusCancel, - model.WorkflowStatusReject: + model.WorkflowStatusReject, model.WorkflowStatusFinish: workflowStatus = req.FilterStatus } From 562604537053649cb0783436c57b371f06c9ef4a Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 13:03:50 +0800 Subject: [PATCH 02/10] fix exec-success status logic check --- sqle/api/controller/v2/workflow.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index 2d4f866ee6..5782edf7ea 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -299,6 +299,22 @@ func GetWorkflowsV2(c echo.Context) error { return controller.JSONBaseErrorReq(c, err) } + if req.FilterStatus == model.WorkflowStatusFinish { + var workFlowTest []*model.WorkflowListDetail + for _, workflow := range workflows { + var hasNotExecutedSuccess bool + for _, status := range workflow.TaskStatus { + if status != model.TaskStatusExecuteSucceeded { + hasNotExecutedSuccess = true + } + } + if !hasNotExecutedSuccess { + workFlowTest = append(workFlowTest, workflow) + } + } + workflows = workFlowTest + } + workflowsReq := make([]*WorkflowDetailResV2, 0, len(workflows)) for _, workflow := range workflows { workflowReq := &WorkflowDetailResV2{ From f1f752d064ff7674e2f600967f2e892db3240b74 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 15:09:46 +0800 Subject: [PATCH 03/10] rename --- sqle/api/controller/v2/workflow.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index 5782edf7ea..b60c9a7862 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -300,7 +300,7 @@ func GetWorkflowsV2(c echo.Context) error { } if req.FilterStatus == model.WorkflowStatusFinish { - var workFlowTest []*model.WorkflowListDetail + var workFlowDetails []*model.WorkflowListDetail for _, workflow := range workflows { var hasNotExecutedSuccess bool for _, status := range workflow.TaskStatus { @@ -309,10 +309,10 @@ func GetWorkflowsV2(c echo.Context) error { } } if !hasNotExecutedSuccess { - workFlowTest = append(workFlowTest, workflow) + workFlowDetails = append(workFlowDetails, workflow) } } - workflows = workFlowTest + workflows = workFlowDetails } workflowsReq := make([]*WorkflowDetailResV2, 0, len(workflows)) From b27334018af8099da7f8d4f2e6399cd2377a8897 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 15:10:47 +0800 Subject: [PATCH 04/10] fix executing status filter --- sqle/api/controller/v2/workflow.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index b60c9a7862..06d69537ce 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -263,8 +263,8 @@ func GetWorkflowsV2(c echo.Context) error { var taskStatus string // task status - if req.FilterStatus == model.WorkflowStatusExecFailed { - taskStatus = model.TaskStatusExecuteFailed + if req.FilterStatus == model.WorkflowStatusExecuting { + taskStatus = model.TaskStatusExecuting workflowStatus = model.WorkflowStatusFinish } From 1b001609cadca30a83010630545a2a9c5f205e38 Mon Sep 17 00:00:00 2001 From: HuangWeiCen <1724659546@qq.com> Date: Fri, 23 Sep 2022 15:35:15 +0800 Subject: [PATCH 05/10] issue_891 fix bug --- sqle/api/cloudbeaver_wrapper/app.go | 2 +- sqle/api/cloudbeaver_wrapper/service/base.go | 4 ++-- sqle/api/cloudbeaver_wrapper/service/user.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sqle/api/cloudbeaver_wrapper/app.go b/sqle/api/cloudbeaver_wrapper/app.go index a417c82f3c..0f60e02cda 100644 --- a/sqle/api/cloudbeaver_wrapper/app.go +++ b/sqle/api/cloudbeaver_wrapper/app.go @@ -182,7 +182,7 @@ func TriggerLogin() echo.MiddlewareFunc { _, isLogin, _ := service.GetCurrentCloudBeaverUserID(c) if isLogin { - return nil + return respFunc() } cookies, err := service.Login(user.Name, user.Password) diff --git a/sqle/api/cloudbeaver_wrapper/service/base.go b/sqle/api/cloudbeaver_wrapper/service/base.go index 17d2febffd..5399860c09 100644 --- a/sqle/api/cloudbeaver_wrapper/service/base.go +++ b/sqle/api/cloudbeaver_wrapper/service/base.go @@ -27,8 +27,8 @@ const ( CBUserRole = "user" ) -func GetGQLClientWithCurrentUser(ctx echo.Context) (*gqlClient.Client, error) { - return gqlClient.NewClient(GetGqlServerURI(), gqlClient.WithCookie(ctx.Cookies())), nil +func GetSQLEGQLClientWithCurrentUser(ctx echo.Context) (*gqlClient.Client, error) { + return gqlClient.NewClient(GetSQLEGqlServerURI(), gqlClient.WithCookie(ctx.Cookies())), nil } func GetGQLClientWithRootUser() (*gqlClient.Client, error) { diff --git a/sqle/api/cloudbeaver_wrapper/service/user.go b/sqle/api/cloudbeaver_wrapper/service/user.go index d3fb68b842..e2bda48ba2 100644 --- a/sqle/api/cloudbeaver_wrapper/service/user.go +++ b/sqle/api/cloudbeaver_wrapper/service/user.go @@ -236,7 +236,7 @@ query authLogin( ` func GetCurrentCloudBeaverUserID(ctx echo.Context) (string, bool, error) { - client, err := GetGQLClientWithCurrentUser(ctx) + client, err := GetSQLEGQLClientWithCurrentUser(ctx) if err != nil { return "", false, err } From 3cc431c7ce7ebd006e3f0c38c7e7a7ec93fc4701 Mon Sep 17 00:00:00 2001 From: HuangWeiCen <1724659546@qq.com> Date: Fri, 23 Sep 2022 15:36:46 +0800 Subject: [PATCH 06/10] issue_891 fix bug --- sqle/api/cloudbeaver_wrapper/app.go | 2 +- sqle/api/cloudbeaver_wrapper/service/base.go | 4 ++-- sqle/api/cloudbeaver_wrapper/service/user.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sqle/api/cloudbeaver_wrapper/app.go b/sqle/api/cloudbeaver_wrapper/app.go index a417c82f3c..0f60e02cda 100644 --- a/sqle/api/cloudbeaver_wrapper/app.go +++ b/sqle/api/cloudbeaver_wrapper/app.go @@ -182,7 +182,7 @@ func TriggerLogin() echo.MiddlewareFunc { _, isLogin, _ := service.GetCurrentCloudBeaverUserID(c) if isLogin { - return nil + return respFunc() } cookies, err := service.Login(user.Name, user.Password) diff --git a/sqle/api/cloudbeaver_wrapper/service/base.go b/sqle/api/cloudbeaver_wrapper/service/base.go index 17d2febffd..5399860c09 100644 --- a/sqle/api/cloudbeaver_wrapper/service/base.go +++ b/sqle/api/cloudbeaver_wrapper/service/base.go @@ -27,8 +27,8 @@ const ( CBUserRole = "user" ) -func GetGQLClientWithCurrentUser(ctx echo.Context) (*gqlClient.Client, error) { - return gqlClient.NewClient(GetGqlServerURI(), gqlClient.WithCookie(ctx.Cookies())), nil +func GetSQLEGQLClientWithCurrentUser(ctx echo.Context) (*gqlClient.Client, error) { + return gqlClient.NewClient(GetSQLEGqlServerURI(), gqlClient.WithCookie(ctx.Cookies())), nil } func GetGQLClientWithRootUser() (*gqlClient.Client, error) { diff --git a/sqle/api/cloudbeaver_wrapper/service/user.go b/sqle/api/cloudbeaver_wrapper/service/user.go index d3fb68b842..e2bda48ba2 100644 --- a/sqle/api/cloudbeaver_wrapper/service/user.go +++ b/sqle/api/cloudbeaver_wrapper/service/user.go @@ -236,7 +236,7 @@ query authLogin( ` func GetCurrentCloudBeaverUserID(ctx echo.Context) (string, bool, error) { - client, err := GetGQLClientWithCurrentUser(ctx) + client, err := GetSQLEGQLClientWithCurrentUser(ctx) if err != nil { return "", false, err } From 239f6556abd222537cb3ddd9d43e87e429a9816c Mon Sep 17 00:00:00 2001 From: HuangWeiCen <1724659546@qq.com> Date: Fri, 23 Sep 2022 15:40:55 +0800 Subject: [PATCH 07/10] issue_891 fix bug --- sqle/api/cloudbeaver_wrapper/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqle/api/cloudbeaver_wrapper/app.go b/sqle/api/cloudbeaver_wrapper/app.go index 0f60e02cda..41aadb1c7b 100644 --- a/sqle/api/cloudbeaver_wrapper/app.go +++ b/sqle/api/cloudbeaver_wrapper/app.go @@ -177,7 +177,7 @@ func TriggerLogin() echo.MiddlewareFunc { user, _, err := s.GetUserByName(userName) if err != nil { l.Errorf("get user info err: %v", err) - return nil + return respFunc() } _, isLogin, _ := service.GetCurrentCloudBeaverUserID(c) @@ -188,7 +188,7 @@ func TriggerLogin() echo.MiddlewareFunc { cookies, err := service.Login(user.Name, user.Password) if err != nil { l.Errorf("login to cloudbeaver failed: %v", err) - return nil + return respFunc() } for _, cookie := range cookies { c.SetCookie(cookie) From 5855ed68ab1c6d7dcd074466227a0c2f63cbdaac Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 15:45:34 +0800 Subject: [PATCH 08/10] fix execute fail case --- sqle/api/controller/v2/workflow.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index 06d69537ce..f4fbf624ed 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -264,14 +264,19 @@ func GetWorkflowsV2(c echo.Context) error { // task status if req.FilterStatus == model.WorkflowStatusExecuting { + // 上线中(所有数据源全部上线,有任一数据源处于上线中状态) taskStatus = model.TaskStatusExecuting workflowStatus = model.WorkflowStatusFinish } // workflow status switch req.FilterStatus { + // 上线成功(所有数据源全部上线成功) + // 上线失败(所有数据源全部上线,但有部分上线失败) + case model.WorkflowStatusFinish, model.WorkflowStatusExecFailed: + workflowStatus = model.WorkflowStatusFinish case model.WorkflowStatusWaitForAudit, model.WorkflowStatusWaitForExecution, model.WorkflowStatusCancel, - model.WorkflowStatusReject, model.WorkflowStatusFinish: + model.WorkflowStatusReject: workflowStatus = req.FilterStatus } @@ -315,6 +320,26 @@ func GetWorkflowsV2(c echo.Context) error { workflows = workFlowDetails } + if req.FilterStatus == model.WorkflowStatusExecFailed { + var workFlowDetails []*model.WorkflowListDetail + for _, workflow := range workflows { + var hasExecuting bool + var hasExecutedFail bool + for _, status := range workflow.TaskStatus { + if status == model.TaskStatusExecuting { + hasExecuting = true + } + if status == model.TaskStatusExecuteFailed { + hasExecutedFail = true + } + } + if !hasExecuting && hasExecutedFail { + workFlowDetails = append(workFlowDetails, workflow) + } + } + workflows = workFlowDetails + } + workflowsReq := make([]*WorkflowDetailResV2, 0, len(workflows)) for _, workflow := range workflows { workflowReq := &WorkflowDetailResV2{ From 92407fc89bdf4022ae3abf933cb6ed46d52dbb80 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 23 Sep 2022 16:01:13 +0800 Subject: [PATCH 09/10] Reduce the number of cycles --- sqle/api/controller/v2/workflow.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sqle/api/controller/v2/workflow.go b/sqle/api/controller/v2/workflow.go index f4fbf624ed..4dac23ff34 100644 --- a/sqle/api/controller/v2/workflow.go +++ b/sqle/api/controller/v2/workflow.go @@ -328,6 +328,7 @@ func GetWorkflowsV2(c echo.Context) error { for _, status := range workflow.TaskStatus { if status == model.TaskStatusExecuting { hasExecuting = true + break } if status == model.TaskStatusExecuteFailed { hasExecutedFail = true From 3e099dc4bce74b59a6a2c1c6929bc8ee06e3a360 Mon Sep 17 00:00:00 2001 From: HuangWeiCen <1724659546@qq.com> Date: Fri, 23 Sep 2022 16:07:38 +0800 Subject: [PATCH 10/10] issue_891 fix bug --- sqle/api/cloudbeaver_wrapper/service/base.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqle/api/cloudbeaver_wrapper/service/base.go b/sqle/api/cloudbeaver_wrapper/service/base.go index 5399860c09..b35bb13844 100644 --- a/sqle/api/cloudbeaver_wrapper/service/base.go +++ b/sqle/api/cloudbeaver_wrapper/service/base.go @@ -71,7 +71,7 @@ func GetSQLEGqlServerURI() string { c := GetSQLQueryConfig() - return fmt.Sprintf("%v://%v:%v%v%v", protocol, c.CloudBeaverHost, c.SqlePort, CbRootUri, CbGqlApi) + return fmt.Sprintf("%v://localhost:%v%v%v", protocol, c.SqlePort, CbRootUri, CbGqlApi) } func InitSQLQueryConfig(sqlePort int, sqleEnableHttps bool, c config.SQLQueryConfig) {