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

export slow queries #792

Merged
merged 16 commits into from
Nov 24, 2020
9 changes: 7 additions & 2 deletions pkg/apiserver/slowquery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package slowquery

import (
"errors"
"fmt"
"github.com/joomcode/errorx"
"net/http"
"strings"
"time"
Expand All @@ -28,6 +28,11 @@ import (
"github.com/pingcap-incubator/tidb-dashboard/pkg/tidb"
)

var (
ErrNS = errorx.NewNamespace("error.api.export")
ErrNoData = ErrNS.NewType("no_data")
)

type ServiceParams struct {
fx.In
TiDBClient *tidb.Client
Expand Down Expand Up @@ -124,7 +129,7 @@ func (s *Service) downloadTokenHandler(c *gin.Context) {
return
}
if len(list) == 0 {
utils.MakeInvalidRequestErrorFromError(c, errors.New("no data to export"))
_ = c.Error(ErrNoData.NewWithNoMessage())
return
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/apiserver/statement/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package statement

import (
"errors"
"fmt"
"github.com/joomcode/errorx"
unbyte marked this conversation as resolved.
Show resolved Hide resolved
"net/http"
"strings"
"time"
Expand All @@ -29,6 +29,11 @@ import (
"github.com/pingcap-incubator/tidb-dashboard/pkg/tidb"
)

var (
ErrNS = errorx.NewNamespace("error.api.export")
baurine marked this conversation as resolved.
Show resolved Hide resolved
ErrNoData = ErrNS.NewType("no_data")
)

type ServiceParams struct {
fx.In
TiDBClient *tidb.Client
Expand Down Expand Up @@ -253,7 +258,7 @@ func (s *Service) downloadTokenHandler(c *gin.Context) {
return
}
if len(overviews) == 0 {
utils.MakeInvalidRequestErrorFromError(c, errors.New("no data to export"))
_ = c.Error(ErrNoData.NewWithNoMessage())
return
}

Expand Down
2 changes: 2 additions & 0 deletions ui/lib/client/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ error:
user:
signin:
invalid_code: Authorization Code is invalid or expired
export:
no_data: No data can be exported
other: Other error
tidb:
no_alive_tidb: No live TiDB instance in the cluster
Expand Down
2 changes: 2 additions & 0 deletions ui/lib/client/translations/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ error:
user:
signin:
invalid_code: 授权码无效或已过期
export:
no_data: 没有可导出数据
other: 其他错误
tidb:
no_alive_tidb: 集群未启动 TiDB 实例
Expand Down