提交 248b2aef 编写于 作者: martianzhang's avatar martianzhang

fix #199

上级 5533b049
......@@ -1460,11 +1460,25 @@ func formatJSON(sql string, db string, suggest map[string]Rule) string {
fingerprint = query.Fingerprint(sql)
id = query.Id(fingerprint)
// Score
score := 100
for item := range suggest {
l, err := strconv.Atoi(strings.TrimLeft(suggest[item].Severity, "L"))
if err != nil {
common.Log.Error("formatJSON strconv.Atoi error: %s, item: %s, serverity: %s", err.Error(), item, suggest[item].Severity)
}
score = score - l*5
}
if score < 0 {
score = 0
}
sug := JSONSuggest{
ID: id,
Fingerprint: fingerprint,
Sample: sql,
Tables: ast.SchemaMetaInfo(sql, db),
Score: score,
}
// Explain info
......
......@@ -2,7 +2,7 @@
{
"ID": "687D590364E29465",
"Fingerprint": "select * from film",
"Score": 0,
"Score": 75,
"Sample": "select * from film",
"Explain": null,
"HeuristicRules": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册