Skip to content

Commit

Permalink
ui: Update space behaviour in statement / slow log search (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine authored Jul 13, 2020
1 parent d11799e commit 6f58636
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
24 changes: 14 additions & 10 deletions pkg/apiserver/logsearch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ func NewService(lc fx.Lifecycle, config *config.Config, db *dbstore.DB) *Service

func Register(r *gin.RouterGroup, auth *user.AuthService, s *Service) {
endpoint := r.Group("/logs")

endpoint.GET("/download", s.DownloadLogs)
endpoint.GET("/download/acquire_token", auth.MWAuthRequired(), s.GetDownloadToken)
endpoint.PUT("/taskgroup", auth.MWAuthRequired(), s.CreateTaskGroup)
endpoint.GET("/taskgroups", auth.MWAuthRequired(), s.GetAllTaskGroups)
endpoint.GET("/taskgroups/:id", auth.MWAuthRequired(), s.GetTaskGroup)
endpoint.GET("/taskgroups/:id/preview", auth.MWAuthRequired(), s.GetTaskGroupPreview)
endpoint.POST("/taskgroups/:id/retry", auth.MWAuthRequired(), s.RetryTask)
endpoint.POST("/taskgroups/:id/cancel", auth.MWAuthRequired(), s.CancelTask)
endpoint.DELETE("/taskgroups/:id", auth.MWAuthRequired(), s.DeleteTaskGroup)
{
endpoint.GET("/download", s.DownloadLogs)
endpoint.Use(auth.MWAuthRequired())
{
endpoint.GET("/download/acquire_token", s.GetDownloadToken)
endpoint.PUT("/taskgroup", s.CreateTaskGroup)
endpoint.GET("/taskgroups", s.GetAllTaskGroups)
endpoint.GET("/taskgroups/:id", s.GetTaskGroup)
endpoint.GET("/taskgroups/:id/preview", s.GetTaskGroupPreview)
endpoint.POST("/taskgroups/:id/retry", s.RetryTask)
endpoint.POST("/taskgroups/:id/cancel", s.CancelTask)
endpoint.DELETE("/taskgroups/:id", s.DeleteTaskGroup)
}
}
}

type CreateTaskGroupRequest struct {
Expand Down
16 changes: 10 additions & 6 deletions pkg/apiserver/slowquery/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ func QuerySlowLogList(db *gorm.DB, req *GetListRequest) ([]Base, error) {

if req.Text != "" {
lowerStr := strings.ToLower(req.Text)
tx = tx.Where("txn_start_ts REGEXP ? OR LOWER(digest) REGEXP ? OR LOWER(CONVERT(prev_stmt USING utf8)) REGEXP ? OR LOWER(CONVERT(query USING utf8)) REGEXP ?",
lowerStr,
lowerStr,
lowerStr,
lowerStr,
)
arr := strings.Fields(lowerStr)
for _, v := range arr {
tx = tx.Where(
`txn_start_ts REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(CONVERT(prev_stmt USING utf8)) REGEXP ?
OR LOWER(CONVERT(query USING utf8)) REGEXP ?`,
v, v, v, v,
)
}
}

if len(req.DB) > 0 {
Expand Down
19 changes: 11 additions & 8 deletions pkg/apiserver/statement/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ func QueryStatementsOverview(

if len(text) > 0 {
lowerText := strings.ToLower(text)
query = query.Where(
`LOWER(digest_text) REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(schema_name) REGEXP ?
OR LOWER(table_names) REGEXP ?
OR LOWER(plan) REGEXP ?`,
lowerText, lowerText, lowerText, lowerText, lowerText,
)
arr := strings.Fields(lowerText)
for _, v := range arr {
query = query.Where(
`LOWER(digest_text) REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(schema_name) REGEXP ?
OR LOWER(table_names) REGEXP ?
OR LOWER(plan) REGEXP ?`,
v, v, v, v, v,
)
}
}

err = query.Find(&result).Error
Expand Down

0 comments on commit 6f58636

Please sign in to comment.