Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update vcs sql review result order (#6830)

ecmadao63e67f84f86d
diff --git a/backend/server/webhook.go b/backend/server/webhook.go
index a01640e874..6894c0bd1e 100644
--- a/backend/server/webhook.go
+++ b/backend/server/webhook.go
@@ -1795,12 +1795,7 @@ func convertSQLAdviceToGitLabCIResult(adviceMap map[string][]advisor.Advice) *ap
testsuiteList := []string{}
status := advisor.Success
- fileList := []string{}
- for filePath := range adviceMap {
- fileList = append(fileList, filePath)
- }
- sort.Strings(fileList)
-
+ fileList := getSQLAdviceFileList(adviceMap)
for _, filePath := range fileList {
adviceList := adviceMap[filePath]
testcaseList := []string{}
@@ -1866,12 +1861,7 @@ func convertSQLAdviceToGitHubActionResult(adviceMap map[string][]advisor.Advice)
messageList := []string{}
status := advisor.Success
- fileList := []string{}
- for filePath := range adviceMap {
- fileList = append(fileList, filePath)
- }
- sort.Strings(fileList)
-
+ fileList := getSQLAdviceFileList(adviceMap)
for _, filePath := range fileList {
adviceList := adviceMap[filePath]
for _, advice := range adviceList {
@@ -1916,6 +1906,27 @@ func convertSQLAdviceToGitHubActionResult(adviceMap map[string][]advisor.Advice)
}
}
+func getSQLAdviceFileList(adviceMap map[string][]advisor.Advice) []string {
+ fileList := []string{}
+ fileToErrorCount := map[string]int{}
+ for filePath, adviceList := range adviceMap {
+ fileList = append(fileList, filePath)
+
+ errorCount := 0
+ for _, advice := range adviceList {
+ if advice.Status == advisor.Error {
+ errorCount++
+ }
+ }
+ fileToErrorCount[filePath] = errorCount
+ }
+ sort.Slice(fileList, func(i int, j int) bool {
+ return fileToErrorCount[fileList[i]] > fileToErrorCount[fileList[j]]
+ })
+
+ return fileList
+}
+
func filterGitHubBytebaseCommit(list []github.WebhookCommit) []github.WebhookCommit {
var result []github.WebhookCommit
for _, commit := range list {