Skip to content

Commit

Permalink
Merge pull request #2835 from actiontech/feat/new_rule_category
Browse files Browse the repository at this point in the history
feat: 规则分类重构
  • Loading branch information
BugsGuru authored Dec 25, 2024
2 parents 4c06f43 + afe2588 commit 497e409
Show file tree
Hide file tree
Showing 20 changed files with 2,006 additions and 1,013 deletions.
2 changes: 2 additions & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
v1Router.GET("/custom_rules", v1.GetCustomRules)
v1Router.GET("/custom_rules/:rule_id", v1.GetCustomRule)
v1Router.GET("/custom_rules/:db_type/rule_types", v1.GetRuleTypeByDBType)
// rule category
v1Router.GET("/rules/categoryStatistics", v1.GetCategoryStatistics)

// task
v1Router.GET("/tasks/audits/:task_id/", v1.GetTask)
Expand Down
310 changes: 268 additions & 42 deletions sqle/api/controller/v1/rule.go

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4356,6 +4356,12 @@ var doc = `{
"description": "fuzzy rule,keyword for desc and annotation",
"name": "fuzzy_keyword_rule",
"in": "query"
},
{
"type": "string",
"description": "tags for rule",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -8409,6 +8415,12 @@ var doc = `{
"description": "fuzzy rule,keyword for desc and annotation",
"name": "fuzzy_keyword_rule",
"in": "query"
},
{
"type": "string",
"description": "tags for rule",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -8614,6 +8626,12 @@ var doc = `{
"description": "filter rule name list",
"name": "filter_rule_names",
"in": "query"
},
{
"type": "string",
"description": "filter tags",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand All @@ -8626,6 +8644,29 @@ var doc = `{
}
}
},
"/v1/rules/categoryStatistics": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get all rule category statistics",
"tags": [
"rule_template"
],
"summary": "获取规则分类统计信息",
"operationId": "getCategoryStatistics",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetRuleCategoryStatisticResV1"
}
}
}
}
},
"/v1/sql_analysis": {
"get": {
"security": [
Expand Down Expand Up @@ -11303,6 +11344,26 @@ var doc = `{
"$ref": "#/definitions/model.AuditResultInfo"
}
},
"model.RuleCategoryStatistic": {
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": [
"audit_accuracy",
"audit_purpose",
"operand",
"sql"
]
},
"count": {
"type": "integer"
},
"tag": {
"type": "string"
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -12505,6 +12566,12 @@ var doc = `{
"rule_script": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"example": "DDL规则"
Expand Down Expand Up @@ -12771,6 +12838,15 @@ var doc = `{
"type": "string",
"example": "this is test rule"
},
"categories": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"db_type": {
"type": "string",
"example": "MySQL"
Expand Down Expand Up @@ -14540,6 +14616,28 @@ var doc = `{
}
}
},
"v1.GetRuleCategoryStatisticResV1": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/model.RuleCategoryStatistic"
}
}
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetRuleKnowledgeResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -16693,6 +16791,15 @@ var doc = `{
"type": "string",
"example": "避免多次 table rebuild 带来的消耗、以及对线上业务的影响"
},
"categories": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"db_type": {
"type": "string",
"example": "mysql"
Expand Down Expand Up @@ -17905,6 +18012,12 @@ var doc = `{
"rule_script": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"example": "DDL规则"
Expand Down
113 changes: 113 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4340,6 +4340,12 @@
"description": "fuzzy rule,keyword for desc and annotation",
"name": "fuzzy_keyword_rule",
"in": "query"
},
{
"type": "string",
"description": "tags for rule",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -8393,6 +8399,12 @@
"description": "fuzzy rule,keyword for desc and annotation",
"name": "fuzzy_keyword_rule",
"in": "query"
},
{
"type": "string",
"description": "tags for rule",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -8598,6 +8610,12 @@
"description": "filter rule name list",
"name": "filter_rule_names",
"in": "query"
},
{
"type": "string",
"description": "filter tags",
"name": "tags",
"in": "query"
}
],
"responses": {
Expand All @@ -8610,6 +8628,29 @@
}
}
},
"/v1/rules/categoryStatistics": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get all rule category statistics",
"tags": [
"rule_template"
],
"summary": "获取规则分类统计信息",
"operationId": "getCategoryStatistics",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetRuleCategoryStatisticResV1"
}
}
}
}
},
"/v1/sql_analysis": {
"get": {
"security": [
Expand Down Expand Up @@ -11287,6 +11328,26 @@
"$ref": "#/definitions/model.AuditResultInfo"
}
},
"model.RuleCategoryStatistic": {
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": [
"audit_accuracy",
"audit_purpose",
"operand",
"sql"
]
},
"count": {
"type": "integer"
},
"tag": {
"type": "string"
}
}
},
"v1.AffectRows": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -12489,6 +12550,12 @@
"rule_script": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"example": "DDL规则"
Expand Down Expand Up @@ -12755,6 +12822,15 @@
"type": "string",
"example": "this is test rule"
},
"categories": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"db_type": {
"type": "string",
"example": "MySQL"
Expand Down Expand Up @@ -14524,6 +14600,28 @@
}
}
},
"v1.GetRuleCategoryStatisticResV1": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/model.RuleCategoryStatistic"
}
}
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetRuleKnowledgeResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -16677,6 +16775,15 @@
"type": "string",
"example": "避免多次 table rebuild 带来的消耗、以及对线上业务的影响"
},
"categories": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"db_type": {
"type": "string",
"example": "mysql"
Expand Down Expand Up @@ -17889,6 +17996,12 @@
"rule_script": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"example": "DDL规则"
Expand Down
Loading

0 comments on commit 497e409

Please sign in to comment.