Skip to content

Commit

Permalink
Merge pull request #478 from actiontech/main
Browse files Browse the repository at this point in the history
merge Main ce to ee
  • Loading branch information
sjjian authored Sep 23, 2022
2 parents a2dad9c + 09281f4 commit 376faf0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
6 changes: 3 additions & 3 deletions sqle/api/cloudbeaver_wrapper/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,18 @@ 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)
if isLogin {
return nil
return respFunc()
}

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)
Expand Down
6 changes: 3 additions & 3 deletions sqle/api/cloudbeaver_wrapper/service/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion sqle/api/cloudbeaver_wrapper/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
50 changes: 45 additions & 5 deletions sqle/api/controller/v2/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,18 @@ func GetWorkflowsV2(c echo.Context) error {
var taskStatus string

// task status
switch req.FilterStatus {
case model.WorkflowStatusExecFailed:
taskStatus = model.TaskStatusExecuteFailed
case model.WorkflowStatusFinish:
taskStatus = model.TaskStatusExecuteSucceeded
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:

Expand Down Expand Up @@ -301,6 +304,43 @@ func GetWorkflowsV2(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}

if req.FilterStatus == model.WorkflowStatusFinish {
var workFlowDetails []*model.WorkflowListDetail
for _, workflow := range workflows {
var hasNotExecutedSuccess bool
for _, status := range workflow.TaskStatus {
if status != model.TaskStatusExecuteSucceeded {
hasNotExecutedSuccess = true
}
}
if !hasNotExecutedSuccess {
workFlowDetails = append(workFlowDetails, workflow)
}
}
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
break
}
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{
Expand Down

0 comments on commit 376faf0

Please sign in to comment.