From 7998b1c600ffa0db4070bd13040e2ab0b1409f72 Mon Sep 17 00:00:00 2001 From: Nut He <18328704+hetao92@users.noreply.github.com> Date: Wed, 2 Jun 2021 14:20:51 +0800 Subject: [PATCH] fix: profile sentence missing data (#20) --- service/dao/dao.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/service/dao/dao.go b/service/dao/dao.go index 869500e..eb4ee8f 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -309,11 +309,11 @@ func Execute(nsid string, gql string) (result ExecuteResult, err error) { resp := response.Result if resp.IsSetPlanDesc() { format := string(resp.GetPlanDesc().GetFormat()) - var rowValue = make(map[string]common.Any) if format == "row" { result.Headers = []string{"id", "name", "dependencies", "profiling data", "operator info"} rows := resp.MakePlanByRow() for i := 0; i < len(rows); i++ { + var rowValue = make(map[string]common.Any) rowValue["id"] = rows[i][0] rowValue["name"] = rows[i][1] rowValue["dependencies"] = rows[i][2] @@ -322,14 +322,14 @@ func Execute(nsid string, gql string) (result ExecuteResult, err error) { result.Tables = append(result.Tables, rowValue) } return result, err - } else if format == "dot" { - result.Headers = append(result.Headers, "format") - rowValue["format"] = resp.MakeDotGraph() - result.Tables = append(result.Tables, rowValue) - return result, err - } else if format == "dot:struct" { + } else { + var rowValue = make(map[string]common.Any) result.Headers = append(result.Headers, "format") - rowValue["format"] = resp.MakeDotGraphByStruct() + if format == "dot" { + rowValue["format"] = resp.MakeDotGraph() + } else if format == "dot:struct" { + rowValue["format"] = resp.MakeDotGraphByStruct() + } result.Tables = append(result.Tables, rowValue) return result, err }